nitika makhija
nitika makhija

Reputation: 11

How to modify client id (cookie value) using google Analytics on click of button?

I am using following line to change the cookie parameter but no change in the clientId/ Cookie Value. Please help me with the solution.

ga('set', 'clientId', "value");

Upvotes: 1

Views: 1467

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

You need to set the client id when you create the tracker:

ga('create', 'UA-XXXX-Y', {
  'clientId': '<my custom clientid>'
});

Once the tracker is created you cannot change it. Changing the client id will end the session and create a new user, so you'll loose all related information (traffic source etc.).

This is documented behaviour inasfar as clientid is listed in the "Create Only Fields" section of the analytics.js field reference.

Upvotes: 1

Related Questions