How can I set _ga cookies using for subdomain only?

Viewed 19

By default, the gtag code sets the domain for the root domain. I implemented the cookie_domain field to my tracking script and now I see the root AND subdomain. I only want to set a cookie for the subdomain. I tried this with the GTM code and it worked, but I need to figure out how to do it for GTAG UA.

<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-XX"></script>
<script>

window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXX-XX', {
  'cookie_domain': '.subdomain.domain.com'
});

</script>
0 Answers
Related