Updating Google Analytics In Drupal
Google Analytics is a great tool to see where people are browsing on your site, to monitor traffic, and possibly some other perks I'm unaware of. ;) So it's important to make sure it still works when you're upgrading the Google Analytics Tracking ID and updating the Google Analytics module, or just updating the module.
Why would you want to do that? Well: The 1.x branch of the Google Analytics module is now no longer supported, so if you want security updates you'll have to update to the 2.x branch (pretty straight-forward).
If you're reading this post, you're likely about to attempt updating this module. I had a hard time finding all this information, so I'm sharing it in a blog post in case anyone else might benefit.
Important: If you have a Google Analytics Classic Tracking ID it needs to be upgraded to the newer Universal Tracking ID in order to work with the 2.x branch of the Google Analytics module.
- Determine Tracking ID type
- Upgrade Tracking ID if needed
- Ensure Tracking ID in module config matches one in Google Analytics account
- Update Google Analytics module
- Update Google Analytics Tokenzier module if necessary
- Check that your site is reporting to Google Analytics
Start with the Tracking ID and find out whether or not yours is the Classic version or the Universal version.
Once you log into Google Analytics, click on the "Admin" link in the top menu. This is what Universal Google Analytics looks like:
If you don't see that, you'll see something below the Property drop-down indicating that your Universal Analytics Upgrade transfer has not started, much like this:
To begin upgrading to the Universal Tracking ID, click "Universal Analytics Upgrade".
Once you've either upgraded or determined that your Tracking ID is Universal, make sure the Tracking ID in your Analytics account matches the Web Property ID in your Google Analytics module settings. Drupal 7:
/admin/config/system/googleanalytics. Drupal 6:
/admin/settings/googleanalytics. This is at the top of the page.
Now you can update the Google Ananlytics module. Since there will be a decent amount of database updates, it would be a good idea to put the site into maintenance mode. If you use Google Analytics Tokenzier, update that as well. Explanation: Older versions of Google Analytics Tokenizer, when used with the 2.x branch of Google Analytics, use a function with deprecated PHP that will cause a WSOD. No passing GO. Right to white.
Last, but not least: Make sure your site is reporting to Google Analytics. Once logged into Google Analytics you'll see a list which will contain a name representing your site. Like so:
Once you click on your site, you should see a menu to the left and content to the right. When you click on "Real Time", it should expand a list. Then you can click on "Content" to see a real time update of who's looking at what, which updates in a matter of seconds. It will look much like this:
When you scroll down the right-hand side you will see a list of pages on your site that people are currently browsing, which will show up almost instantly when you click around your own site. Choose a page that isn't already in that list so it's easier to tell.
If your site isn't reporting, double-check that your Tracking ID matches the Web Property ID in the Google Analytics module config and check the recent log messages to see if anything is interfering.
About The Author
Jack of all trades, master of some; Liz brings a unique element to the team. She has an enthusiastic interest in security and technological structure, which spear-heads her problem solving endeavours. She began her experience with modern technology as a child, messing about in DOS, figuring out how things worked and what she could get away with. Fourteen years ago she delved into C programming within Linux, then Linux systems administration and web programming using the LAMP stack soon after.