After working with Tealium support, we implemented a variation of the solution @ahrasch provided. As described, we used a custom task. However, we did this in an extension, rather than by modifying the tag template. And to supplement this, for the possible occasions where timing causes the tag to fire before the value is provided, we are also storing the value in a session cookie. In this solution, there is still some possibility of the Client ID not being captured on the very first pageview hit, but so far we are seeing it capture 100%, and we also know that most of our pages have at least one event hit after the pageview.
So, the solution involves creating one first party cookie variable (as utag_main_gaClientId), mapping this to the custom dimension in the tag (we used custom dimension 9, after creating this in our GA property settings), and then creating the following javascript code extension, scoped to our GUA tag only:
ga(function() { var trackers = ga.getAll(); for (var i = 0; i < trackers.length; ++i) { var tracker = trackers[i]; var trackerName = tracker.get('name');
ga(function(trackerName) { utag.data['client_id'] = tracker.get('clientId'); utag.loader.SC("utag_main", {"gaClientId": utag.data['client_id']+";exp-session"}); ga(tracker.get('name') + '.set', 'customTask', function(model) { model.set('dimension9', model.get('clientId')); }); }); } });
... View more