user1440273
user1440273

Reputation: 31

Can gtag.js be configured to send GA4 event data to two different GA4 Measurement IDs?

We would like to send GA4 event data to 2 different GA4 Measurement Ids. Can gtag.js be configured to do this?

We know this can be configured for UA and GA4, but what about two or possibly more GA4 Measurement Ids?

Upvotes: 1

Views: 1252

Answers (1)

darrelltw
darrelltw

Reputation: 2372

Yes you can set up the gtag like thie

enter image description here

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-111111111"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-111111111');
  gtag('config', 'G-222222222');
  gtag('config', 'G-333333333');
</script>

Then when you fire event:

enter image description here

<script>
  gtag('event', 'test', {
    'test_p1': 'test_v1'
  });
</script> 

You will send the ga4 event hits to all the config measurement in gtag.

enter image description here

But if you have more complicated requirements like

  1. Event A to all config

  2. Event B to some of the config

Please take a look at the document

Upvotes: 2

Related Questions