Analytics
4.7K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

Total Pageviews, UA via GTM vs UA in Html

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

I work for a site with millions of views and we were recently trying to migrate it from Google Analytics to Universal Analytics.

 

We tried installing UA via GTM, not removing GA to compare the results from one vs the other, we were expecting a difference and we wanted to have a better idea of what that difference was, but what we found was a discrepancy of ~20,000 pageviews, present in GA but missing from UA.

 

Since that was not expected at all we started to debug our site, checking where the GTM tag was not included or not firing, we didn't find any problems with that, so after several tries to change the GTM and our code and waiting some days to check if the result was closer we decided to stop using GTM and inserting the UA javscript code directly into our pages, what we saw was the difference dropping from ~20,000 to ~500 which is within the results we were expecting at first.

 

Is there a reason for this kind of results? does anybody else have had a similar experience?

 

Thanks!

Total Pageviews, UA via GTM vs UA in Html

[ Edited ]
Participant ✭ ✭ ✭
# 2
Participant ✭ ✭ ✭

Hi Juan,

 

Where did you place your GTM snippet, in the <head> or in the <body>?

I guess you placed the UA snippet immediately before the </head> tag. Am I right?

 

Looking forward to hearing from you.

Taavi

 

Total Pageviews, UA via GTM vs UA in Html

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Taavi,

 

The GTM snippet is the first tag right after <body>

and you are correct! the UA snippet is the last tag before </head>

 

Thanks for your interest!

 

Total Pageviews, UA via GTM vs UA in Html

[ Edited ]
Participant ✭ ✭ ✭
# 4
Participant ✭ ✭ ✭

Great to hear from you.

 

Try to place your GTM snippet before the closing </head> tag and copy-paste (leave) the entire <noscript> in the beginning of <body> if you’re concerned about non-JavaScript users. I guess, you already now that an <iframe> is embedded content, and in HTML5, embedded content is never allowed in the <head> of the document.

 

GTM and UA are both asynchronously loading JavaScript libraries, meaning that the browser doesn't need to wait for the snippet to finish loading to continue rendering elements that come after it on the page. It means that you can safely put both snippets at or near the top of your page. The earlier you start loading the library, the more chance your tags (UA tag as well) will have to fire and complete before the user leaves the page or closes the browser. This might result in an increase in data collection accuracy.

If the snippet is toward the end of the page or placed in the <body> and the page takes a significant amount of time to load, it's possible that the user could navigate away (click a link or close the browser window) before the tracking code has loaded, meaning you would miss capturing data about that pageview.

 

Google has recently changed the official documentation as well: https://developers.google.com/tag-manager/quickstart

 

Let us know how it goes. It would be interesting to see the difference.

Taavi