How to change cookie domain in google analytics & google tag manager?

by shanie.wisozk , in category: SEO Tools , 4 months ago

How to change cookie domain in google analytics & google tag manager?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by cameron_walter , 4 months ago

@shanie.wisozk 

To change the cookie domain in Google Analytics and Google Tag Manager, follow these steps:

  1. Google Analytics: Log in to your Google Analytics account. Navigate to the Admin section. In the Property column, click on "Tracking Info" and then "Tracking Code". Look for the line of code that starts with ga('create'. Add the following line before the ga('create' line: ga('create', 'UA-XXXXX-Y', {'cookieDomain': 'yournewdomain.com'});. Replace 'yournewdomain.com' with your desired domain. Save the changes and update the tracking code on your website.
  2. Google Tag Manager: Log in to your Google Tag Manager account. Open the desired container for editing. Go to the "Tags" section. Find the Google Analytics tag and click on it to edit. Under "Tag Configuration", click on the "More Settings" option. Expand the "Fields to Set" section. Add a new field with the name cookieDomain and set the value to yournewdomain.com. Save the changes and publish the container.


Note: Make sure to replace 'yournewdomain.com' with your actual domain name where you want to set the cookie. Also, remember to update the tracking code or the container code on your website after making these changes.