Analytics
1.8K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

Segment data on visitor cookie usage?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi

 

I've searched for information if GA can track if a specific third party cookie is set in a visitors web browser. And if so, if that tracking data can be used for segmentation of data in reports.

 

 

Ex: Visitor X arrives to my website. A third party cookie Y has earlier been set in visitor X's web browser when he/she interacted with another web application. Now, can GA track the existence of cookie Y and send that tracking data into my analytics system for use in reports? For example for segmentation of visitor behaviour.

 

/Axel

Re: Segment data on visitor cookie usage?

Participant ✭ ✭ ☆
# 2
Participant ✭ ✭ ☆

You can use custom dimension with session scope to send this information to GA.
First you must create new custom dimension in Google Analytics.
Go to Admin > Custom Definitions > Custom Dimensions, add new Custom Dimension, set name whatever you want and choose scope to "session".

 

Then you have to modify tracking code on your website. Place this code before ga("send","pageview"); 

 

if(document.cookie.indexOf("yourCookieName") != -1){

    ga('set', 'dimension1', 1);

}

 

This will send dimension1=1 with pageview hit and all hits with this session will have dimension1 set to "1". Ofcourse you can set dimension1 to other value and if you already have some other dimension in your configuration you have to use proper index value (dimension2, dimension3....).

 

Then you can create segment based on dimension1=1 (or whatever you'll set).

 

This only works when you are using Universal Analytics code on your website.
When you create new custom dimension you have to wait some time (about 24 hours) before it starts working.

 

Re: Segment data on visitor cookie usage?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

If I wanted trigger this on a specific value of a given cookie, would it look like:

 

if(document.cookie.indexOf("yourCookieName=yourValueName") != -1){

    ga('set', 'dimension1', 1);

}

?

Segment data on visitor cookie usage?

Participant ✭ ✭ ☆
# 4
Participant ✭ ✭ ☆

Yes, exactly!