Manually setting the Google Analytics Client ID - google-analytics

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/

Related

Google Analytics track to Initial Referrer

A user clicks on a referring link to visit our eCommerce website, but does not yet place an order. Then the user goes back directly to our website at a later point and places an order. How can we set up in google analytics / tag manager that the initial referrer should stay the referrer for this user?
Example: A customer visited example.com and clicked on a link to our website. Then the customer bookmarked our website url. Then at a later point, the customer visits our website through the bookmark or through a Google search. How do we track that example.com was the original referrer for this customer?
Thank you for your help.
If the user returns with the bookmark, the previous source will automatically result as a consequence of the standard Google Analytics attribution model. While if accessed from organic search this will overwrite the previous source.
What you can do to save the first source is to install a cookie on the user's browser so that the first time it saves the source in a custom dimension, while if the cookie already exists it does not save it.

Tracking Pageviews based on Referrer

My goal is to track a user session when a visitor is sent from a specific website.
I would expect visitor from 2 websites: a.com and b.com
I would want trigger a tag 1 if referrer contained a.com
and trigger tag 2 if referrer contained b.com. Once a user lands on my site, they would be expected to travel around many pages on my domain. I still would need to track that session even though the HTTP Referer is no longer matching a.com.
My goal is to track how many of these sessions get sent from a.com, how many from b.com and how many reach of each reach a thank page at /thankyoupage
How would this be configured ?
Would this require session scope and if so, how would this be configured ?
If you just want to see this in Google Analytics you can create a segment with referrer a.com or b.com (mind that in GA the referrer is a traffic channel and only filled if there are not campaign parameters present on the landing page url). So for Analytics you do not need extra work. Traffic channels are automatically in session scope (as a change in channel starts a new session).
If you want to fire a tag conditionally based on the referrer it get's a tad more complicated. GTM does not maintain sessions, and does not, by itself, transfer information between page views. So you need to store the info yourself.
You would use the built-in referrer variable in a trigger that fires a tag if the referrer does not match your own domain. You would use that to fire a custom html tag with a Javascript function that sets a cookie. You then set a cookie with the referrer.
On your thankyou page you use the built-in cookie variable to read your cookie. If the cookie contains a.com or b.com respectively you use that for triggers that fire the appropriate tags (pageview trigger, fire on some pageviews, filter "[your cookie variable] equals a.com" (or b.com)). Since cookies are domain specific this only works when your thankyou page is on the same domain.
I don't think you need to do any configuration for this.
For referral traffic, you can see the acquisition report. It should show up with a source as a.com and b.com.
for reaching the thank you page, I'd suggest you set up goals based on the arrival of the thank you page.
As per my understanding, you want to have cross-domain tracking and want to track below thing:
Page 1of a.com --> Page 2 of a.com --> Page 1 of b.com --> page2 of b.com
By default whenever the domain changes User's GA ID is changed. So for a.com and for b.com GA will treat the same user as different, so by default, you cannot track such things.
To track above scenario GA should consider that the user on both the site is same And to do that GA provides Cross Domain tracking using Linker
https://developers.google.com/analytics/devguides/collection/analyticsjs/linker

Google Tag Manager _ga querystring issue

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.

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