- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
03-31-2015 05:35 AM - last edited on 10-06-2015 09:19 AM by kathleen_jo
I was thinking that I could set up an extension with this piece of code (as indicated by google here: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains?hl=en#getClientId)... but it's not working....
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
That will return the value that Google uses to identify a client (i.e 1212837214.1427804483)
I've tried with all kind of js extensions pre-loader, dom ready and all tags... but it seems that the ga function is not defined in any of them...
Any help will be more than welcome!
[Using the _ga cookie is not an option as we want to have this information ready by the first time the collect pixel is called ]
Thanks!
03-31-2015 01:29 PM
04-01-2015 07:46 PM - last edited on 10-06-2015 09:19 AM by kathleen_jo
Hi Marta, The support article that you link references the 'ga' function in the context of analytics.js This is the file used by Google Universal Analytics while ga.js is used by the standard(and premium) Google Analytics - see the link provided above. My suspicion is that you are using the standard GA tag but calling a function that is only present in the GUA tag. If we are on the right path here, I would add the GUA tag, then add a javascript Extension with your tracker.get function, then scope that Extension to the GUA tag. You may need to adjust sequence as you've described in your other efforts(pre-Loader, DOM Ready) to see when/where the funtion needs to fire.
For added help, if you could provide a link to where you are testing(tagmania site?) and the Account / Profile one of our service engineers can take a quick look and offer suggestions.
10-06-2015 09:23 AM
10-06-2015 09:40 AM
Finally, I've been able to do what I want (sending the clientId value as a custom dimension to GUA) by setting up a js extension that looks like this:
$waitUntil(
function () { return (typeof ga !== 'undefined' && typeof ga.getAll === 'function'); },
function () {
trackers = ga.getAll();
if(trackers.length) { utag.view({ client:trackers[0].get('clientId')}); };
},
200,
2000);
}
What it does is:
- waits until the GUA tracker is loaded
- gets the clientId assigned to the visitor
- calls utag.view to call the GUA tag where the client is mapped as a custom dimension.
The drawback is that it generates duplicates the page views, as a page view is sent automatically when analytics.js library is loaded and I'm unable to skip it...
Is it possible to set up the GUA tag to avoid the initial page view?
Copyright All Rights Reserved © 2008-2023