Enable SSL for Google Analytics

Unsecure Google Analytics Warning

If you use the unsecure Google Analytics code on one of your secure web pages your web browser will warn that there is some page content that is not secure. This problem can be easily solved by slightly changing the code used to load Google Analytics.

Instead of:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

Use:

<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"> 
</script>

If you still get the "page contains secure and nonsecure items" after changing that code you should check for other page elements that are using http instead of https.

Google's information about using SSL with Google Analytics is also available.

Update: Google has now updated the Google Analytics code to use ga.js instead of the urchin.js file. In the process, they have implemented code that will automatically detect whether http or https needs to be used. The new code will also enable new features so it is recommended that you upgrade. This will solve the SSL problem so you won't need to worry about the solution above. The upgrade instructions can be found here.

Originally posted on Mon Oct 8, 2007