_ga User ID not collected on the first interaction with the website

Gold Contributor
Gold Contributor

Dear Community,

 

we collect the _ga User ID from the _ga cookie and place it into a custom dimension through a "Set Value" extension which is mapped to the tag.

 

Unfortunately this value becomes available when the _ga cookie is generated which happens when the GUA tag fires and therefore the custom dimension is not populated on the first interaction with the website.

 

Are you aware of any solution to fix this?

 

Thank you very much in advance for your help.

 

KR,

Mattia

 

 

 

 

4 REPLIES 4

_ga User ID not collected on the first interaction with the website

Gold Contributor
Gold Contributor

Anyone can help on this one?

 

Please :)

 

Thank you very much.

_ga User ID not collected on the first interaction with the website

Tealium Employee

@defelicemattia

 

My guess is, your best bet is a JS extension scoped to "end" that reads the cookie. And then fires an event to GUA.

Something like this:

 

gua_cookie.png

 

Adrian

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.

_ga User ID not collected on the first interaction with the website

Gold Contributor
Gold Contributor

Thank you very much @adrian_browning

 

How would the code look like if we want to apply this only to the first page on the first session? Because that is where we miss the value with our current implementation.

 

 

After that the cookie will be already set in the browser and and the cd will get populated with the GUA tag.

 

thanks again for your help.

_ga User ID not collected on the first interaction with the website

Tealium Employee

@defelicemattia So you would want to wrap it like this:

 

if (!utag.data["cp._ga"]) {
  var _ga_id = document.cookie.match(new RegExp('_ga=([^;]+)'));
  ga('send', 'pageview', {
    'dimensionXX':  _ga_id
  });
}

This would stop it firing if that cookie is present.

 

Adrian

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Public