Google Tag Manager _ga querystring issue - google-tag-manager

I am facing a weird issue with GTM.
I have one main domain and several sub-domains.
I have main site on http:://abc.com and I have ads delivering from http://ads.abc.com
Now GTM automatically ads the _ga tag to the banner pointing to an outside domain. I am fine with it adding the _ga tag but the querystring starts with "&" instead of starting it with "?" that breaks the url pointing to the banner.
Here is my url to the banner:
http://ads.abc.org/www/delivery/ck.php?oaparams=2__bannerid=103__zoneid=11__cb=4e3789c636__oadest=http%3A%2F%2Fwww.outsideurl.com.com%2Fsolution&_ga=1.35617777.1606009999.1489075858
Does GTM has some kind of configuration where I can define ads.abc.com as a part of abc.com and it wouldn't add cross-domain _ga tag OR is there anything where I can prevent the _ga tag from being added to the url starting with ads.petrowiki.org
I am using Revive ad server to deliver the ads. I know for sure that it has nothing to do with the Ad server but just in case..

That is the Google Analytics cross-domain "Linker" feature, which may or may not be related to your GTM implementation.
You can disable it by removing the ga('require', 'linker'); command or disabling linker:autoLink.
If you are configuring GA via GTM, you can add a "Field to Set" setting of allowLinker, value false.

Related

404 error for page view event, google tag manager or application?

When i check console in Chrome DevTools i see the 404 error above. Pasted example below:
POST https://www.example.com/g/collect?v=2&tid=G-XXXXXX&gtm=2oe8b0&_p=424137054&sr=1366x768&ul=en-us&cid=1940949659.1614938183&_s=1&dl=https%3A%2F%2Fwww.example.com%2Fmovies%2F&dr=https%3A%2F%2Fwww.example.com%2Fcasts%2F&dt=Movies%20Free&sid=1628778501&sct=16&seg=1&en=page_view 404
I don't know where to start debugging, is this a google tag manager or google analytics error? Every time a page on website is viewed, this error is displayed in console. The route "/g/collect" doesn't exist on my application. How do i solve? Do i have to create the route on my application or change something in tag manager?
The path is from a tracking call to GA4 (recognizable by the /g/collect route and the v=2 parameter, which refers to measurement protocol version 2).
If that is actually your own domain in that request, then it is possible that somebody has changed the "transport_url" property in the GA4 configuration in the "Fields to set" section of the GA4 configuration tag.
Or somebody set the "Send to Server Container" option and added your domain, which is essentially a nicer UI for the same feature.
If you have not configured the route on your server, this will result in a 404. You would configure this only if you run a proxy for you GA4 calls or want to use server-side Google Tag Manager. If you do not want to do that, just remove the setting.
For client-side GA, the endpoint should be: https://analytics.google.com/g/collect
For example:
https://analytics.google.com/g/collectv=2&tid=G-XXXXXX&gtm=2oe8b0&_p=424137054&sr=1366x768&ul=en-us&cid=1940949659.1614938183&_s=1&dl=https%3A%2F%2Fwww.example.com%2Fmovies%2F&dr=https%3A%2F%2Fwww.example.com%2Fcasts%2F&dt=Movies%20Free&sid=1628778501&sct=16&seg=1&en=page_view
Are you sending to https://www.example.com/g/collect or was this used for demonstration purposes?
The only time that endpoint would be different for any GA property is if you're sending data to a Server-Side GTM container.

Manually setting the Google Analytics Client ID

I have a sub-domain that I am unable to put GTM or GA tracking code on. I have GA on the main domain.
I can retrieve the _ga cookie and get the Client ID but but if a user has not been to the main website they won't have one.
My question is:
Can I set a cookie called _ga (in the same format as GA sets it) and will this get picked up by GA if the user then goes back to the main website?
This article seems to be what you need:
Cookie Settings And Subdomain Tracking In Universal Analytics
https://www.simoahava.com/analytics/cookie-settings-and-subdomain-tracking-in-universal-analytics/

_ga querystring, is this part of classic or universal google analytics

I help manage a site that had classic google analytics installed and it has recently migrated to universal analytics via Google Tag Manager.
Now when travelling to a subdomain google is appending the cookie information to the anchor, as a querystring value.
?_ga=1.94005085.150702697.1452253355
Apparently this has didn't happen with classic analytics, even though the set up is like this:
pageTracker._trackPageview(getPageUri(true));
pageTracker._setAllowLinker(true);
Does anyone know if the url will be changed when travelling to a sub domain on classic analytics with the above options?
This is down to how your cookies are setup. For hypothetical purposes assume that your website and subdomain are:
www.website.com
subdomain.website.com
These domains can share a cookie and therefore share the Google Analytics information however unless you specifically set the custom variable of cookieDomain to auto (with GTM tag setup: #3 Configure Tag > More Settings > Fields to set > + Add Field > cookieDomain | auto) you essentially have two distinct cookies for each domain.
I also presume you have then also setup "Cross-Domain Tracking" and included "website.com" within "Auto Link Domains" setting in GTM.
TL;DR: Updating your cookieDomain settings to utilise "auto" will force GTM to first attempt to set a cookie for .com (which will fail) and then attempt to set one for "website.com" (will work work) and your cross domain tracking won't be required.
Bonus info: However to add some context for your question the code pageTracker._setAllowLinker(true); allows the linker to be applied to URL's in Classic Analytics, you would still need to decorate your links with code such as below, if you didn't have this before your links wouldn't have included the linker code (and wouldn't have shared cookied if on different cookie domains/paths).
<a href="http://www.my-example-blogsite.com/intro"
onclick="_gaq.push(['_link', 'http://www.my-example-blogsite.com/intro.html']); return false;">
See my blog</a>

Preserving cross domain GA on mobile redirect, how to do this properly?

I have a site, let's say test.com. This incorporates Google Tag Manager. I have a console for booking, this goes to a different domain. So the form's action is say, bookings.anotherdomain.com.
When the form is submitted, the URL becomes bookings.anotherdomain.com/?_ga=TOKEN. From what I understand, _ga is the new param for all google tracking, all the utm params are stored for it in google's database.
On bookings.anotherdomain.com, for the moment this site is not fully responsive and has a "sniffer" script that redirects to mobile.yetanotherdomain.com. Yes, that's 3 different domains.
The problem is during the redirect from bookings.anotherdomain.com to mobile.yetanotherdomain.com, no GA params are passed. This redirect happens via server side.
I'm wondering if the proper procedure would be to pass the _ga variable?
$ga = '?_ga=' . htmlspecialchars( $_REQUEST['_ga'] );
header('Location: mobile.yetanotherdomain.com/' . $ga );
exit;
Would this be the right way of sending the GA params? I can't use JS for this as I want to keep it a server-side redirect, so that eliminates any GA JS script calls.
The short answer to your question is yes, forward that URL parameter if you can.
It sounds like you're using the analytics.js linker plugin, which is designed to do cross-domain tracking. Analytics.js keeps track of a particular user on a domain by storing a client ID value in a cookie. So, in order for analytics.js to track a particular user when she leaves domain A and goes to domain B, that client ID must be passed somehow. That's what the _ga=TOKEN URL parameter is -- the client ID.
In order for the destination domain to know to check for that _ga URL param, you have to tell your tracking code to expect it. The developer guide I linked to above should explain how to do that.
This site also has some good information on cross-domain tracking:
https://support.google.com/analytics/answer/1034342
I hope that helps; let me know if you want more details.

UTM source getting overriden with referral when going to subdomain

I have a site http://test.com. Potential customers are sent to that site with AdWords with a UTM source, so for example, http://test.com?utm_source=adwords. Now if the customers decide to register, they are sent to a page at http://register.test.com. I've configured Google Analytics to work cross domain using _gaq.push(['_setDomainName', '.mysite.com']);, but the problem I'm having is that my source gets lost and replaced with a referral to the original domain when I go to the subdomain's page. I tried adding a _gaq.push(['_addIgnoredRef', 'ekomobi.com']);, but that only causes my source to be set to (direct).
I will be trying to save the __utmz cookie's value and restore it on the other domain, but are there any other proper solutions to the problem of the UTM source getting overriden by the referrer on a domain change?
If you have cross-domain tracking correctly implemented, you should see the original utm parameter when you get to the register page. For cross domain tracking to work, BOTH top-level domain and subdomain must have _gaq.push(['_setDomainName', '.mysite.com']);,.

Resources