Question

I'm using analytics.js and Google tag manager to track my website.

Given that a custom dimension of scope session is 'last value wins' I am wondering if it is possible to have a 'first value wins' dimension in GA?

Is it possible, or a very bad idea, for example, to sync up my own custom cookie value with the expiration time of the user's GA analytics session?

According to this post

Google Analytics will end a session when: 1. Greater than 30 minutes have elapsed between pageviews for a single user 2. At the end of a day 3. When any campaign information for the user changes. Campaign information includes: utm_source, utm_medium, utm_term, utm_content, utm_id, utm_campaign and auto-tagging from AdWords (gclid)

I want to know what section of the site my users enter on or visit first, and not reset that if they visit another section before leaving. I want that set when the user first sets that custom dimension (that is, only if it's not set yet during the session). I could attempt to implement my own logic that mirrors the above expiration scenarios, but that could get ugly and I'd rather not reinvent the wheel.

I was thinking it would be cool if you could ask the tracker object on the page what its session timeout should be for syncing with it. The cookie itself expires in 2 years and the logic it uses to determine whether a session is new or not is obfuscated.

Was it helpful?

Solution

phpguru,

What you could do is to create two custom dimensions and to achieve "first value wins" dimension simply set it only once per session. This could be easily done with Google Tag Manager using session cookies (see this post with detailed how-to instructions).

Then you can have "regular" custom dimension with last value wins, if needed.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top