I added a new account / property in Google as normal
I added the GA property ID into lib\config.php
I checked in Google Analytics real-time and it was showing me as a
visitor
All seemed fine, however when I checked my Google Analytics a couple of days later there were no visitors.
I think I have found what my issue is. When creating a property in Google Analytics you’re given a choice “Universal Analytics” or “Classic Analytics”. I chose classic but js code in roots assumes universal.
I have now created a 2nd Analytics property, chose Universal and used that ID - I will have to wait 24 hours to see if that fixes it. Looking at the js I think it will
I think the same issue may arise with other choices in Google Analytics that cause GA to generate different JavaScript e.g. subdomains, eCommerce. Google also rolls out different features across different countries at different times. So I think it would be very difficult to try and support every combination in roots over time.
My suggestion: instead of the just adding the GA property ID into lib\config.php cut/paste all the JS from Google Analytics.
We’re using HTML5 Boilerplate’s optimized GA snippet. Even prior to Universal Analytics it differed from what GA tells you to use, so we won’t be making it so that people copy and paste the snippet from GA into Roots (if we were doing that we might as well completely remove any mention of GA in Roots).
We could add a note mentioning that it needs to be a Universal Analytics property in lib/config.php
Google says it can take up to 24 hours. I have seen it working within 12 hours but seems to vary
There is an extension “Google Analytics Debugger” on Google Chrome Web Store that shows what Google Analytics is capturing - but still worth checking in GA the next day
Still waiting for the tracking to kick in. Strangely the Real Time stuff works.
I’ll look into the debugger. Off the bat though, I notice there is a site name parameter missing in the Boilerplate stuff, compared to the snippet GA provides, on the ga.create function:
Is there a way to completely remove the Analytics script that is built into the theme? I prefer to use the Google Tag Manager to deploy Analytics tags which requires the code to be installed after the opening tag. Any advice on this would be greatly appreciated.
I think its a good idea to implement tag manager instead of GA by default. Tag manager gives you a lot more flexibility and you only have to implement one tag, in one place.