I am experiencing a very strange problem with Google tag manager (GTM), Google analytics (GA) and Google adwords. So far I am getting nowhere with solving it.
The setup:
We have a singe page application (backbone and marionette) and we are using GTM to push virtual pageviews to GA using standard dataLayer.push events (and also e-commerce events if this is relevant). This setup generally works fine.
The problem:
The problem is users coming from adwords, with a gclid tag. The first pageview for these users is tracked and attributed do the adword campaign correctly, but as soon as they click any link on the site they seem to get a new session in GA, and the original session is then counted as a bounce. All pages are on the same domain, and we have verified that these campaign users are not actually bouncing, they are still on the site but are somehow mislabeled by GA.
I.E.
Important note: This problem only occurs with campaign visitors! Users without a campaign tag don't get new sessions when they click links.
Has anyone experienced a problem like this before? Is there any special things to take into account when using adwords via GTM on a single page app? What could cause Google analytics to lose track of a session like this?
The site in question is https://fyndiq.se, in a mobile (it uses dynamic serving, the problem is not there on the desktop version which is not a SPA).
Edit - A summary of the problem and the current, imperfect, solution
We have managed to get to an acceptable level with this, but it is far from perfect. Since the solution is all spread out in the comments I thought I would summarize the result here.
The problem is indeed that Analytics creates new sessions for Adwords users, losing track of the campaign. Analytics will start a new session for a user on a few different conditions. The most common are when the user has been inactive for 30 mins, when the user enters the site from a new campaign, and when the user enters the site from a known search engine.
The last two are the issue here. Google judges these condition based on the combination of campaign tags (gclid or utm_) and referrer, and on a single page application referrer does not update!
I.E.
To prevent this we ended up doing two things. First we manually send a referrer to Google Tag Manager (if none is sent it defaults to document.referrer, which as said above does not update). On the first pageload we use the real referrer, so that hits get attributed correctly. On any subsequent pageload we send our own domain as referrer, like it would have been on a non SPA. This tells analytics that we are routing internallyand that it should not start a new session.
The referrer can be sent to GTM the same way as you send a virtual pageview url and is (at the moment of writing) set in the same place as url and pagetitle. We make sure this is done on ALL events sent to analytics, not only the pageviews.
The second thing comes from Jareds answer below, we make sure to set page and not just location (see below for why these are different). Page can be set in the advanced settings in GTM. Only one of these two things should be needed, but we did both just to be safe.
This seems to give us mostly correct data. We are still missing about 15% of the cpc transactions compared to the data from adwords but it's hard to know how close to done we really are. Adwords and analytics do not measure the same thing, so a diff is to be expected and the size of the diff will vary from page to page. It is however enough for us to use for testing and marketing, so it will have to do for now.
If anyone finds a solution that is more consistent, please write a new answer!
By default, Google Tag Manager does NOT use cookies because GTM is just a middle man between your website and marketing/analytics tools you have installed. Google Tag Manager does not store any personal data about visitors.
Google Tag Manager (GTM) is a Google product that helps SEO professionals gain much more insight into what is happening on a Website. GTM also provides a way to easily add tags and triggers as well as add things like Google Analytics and other SEO related software.
But when you have the chance to set everything up through GTM, that is still the preferred option. If this is not possible, you can certainly use gtag. js and GTM side by side, but make sure that only one pageview is fished. That way you avoid duplicate data and can take advantage of the benefits of both gtag.
Does Google Tag Manager slow down the site? The most absolute answer is yes. Just like any additional line of code added to the site, it will have some impact on the page loading speed.
We at betabrand.com are having very similar troubles.
Last month we switched from a multipage to a single page app using angularJs and immediately starting getting bad advertising revenue tracking both Universal Analytics and Google Analytics.
We are also using Google Tag Manager to fire off our events.
Our current lead is a tidbit from https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications
Which states:
Do not update the document location
In the same way that the tracker uses document.referrer for the referrer field, it uses document.location for the location field, which will often contain campaign data or other meta data in the form of query parameters appended to the end of the URL.
Updating any of the campaign fields or other meta data that Google Analytics is checking for may cause the current session to end and a new session to begin. To avoid this problem, do not update the location field when tracking virtual pageviews in a single page application. Use the page field instead.
It also includes this note
Note: if you send a hit that includes both the location and page fields and the path values are different, Google Analytics will use the value specified for the page field.
To us, this says that if you include the 'page' field it will trump a 'location' field value and that if you include a 'location' field without a 'page' field after the initial page load you run the risk of starting a new session possibly with the campaign tracking stripped.
Using the google analytics debugger chrome extension we were able to identify events that were indeed firing a location parameter and without a page parameter.
A user hits our page, GTM fires a page view with the 'location' parameter. Subsequent virtual page views were including both 'location' and 'page' parameters. However we were also firing an event when a user opens their shopping cart that and that includes a 'location' parameter and not a 'page' parameter.
We just updated our GTM configuration to try to remedy this and have our fingers crossed that it will work. I'll update my post if we find a solution.
We've been wrestling with this for WAY too long now.
I'm facing the same problem (currently implementing the solution.. only did some research) and it might have something to do what Google only is mentioning in their docs briefly, namely: Do not create new trackers. GTM does create a new tracker each time..
Possible solution
Do not let GTM initiate a new tracker each time but set trackerName in GTM like 'spaTracker' for your Single Page App.
All credits go to Thyngster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With