|
May 23
2007
|
Google-analytics under SSLPosted by brian in Tech, E-Commerce |
|
So, here is the senario... you have an online store, you want to use google analytics to track visits/conversions etc... so you add the urchin tracker code like they say to. Now when you go to checkout or go under any ssl encrypted page the sight throws an error saying there are secure and non-secureitems....
The default code they give is
< script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
The problem here is that it's including urchin from a non-secure source, I found some javascript at this guys blog ... http://boagworld.com/forum/comments.php?DiscussionID=1324
which will allow us to detect SSL encryption and pull in the urchin from the proper source, so use this instead.
< script type="text/javascript">
document.write( '<scr'+'ipt type="text/javascript" src="' );
if( document.location.toString().indexOf( 'https://' ) != -1 ) {
document.write( 'https://ssl' );
} else {
document.write( 'http://www' );
}
document.write( '.google-analytics.com/urchin.js"><\/scr'+'ipt>' );
</script>
Obviously I took the opening bracket off the script tag... but you get the picture
del.icio.us · digg this · spurl · reddit · furl this
Blog 
