Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine Google Analytics and Google AdWords gtag.js?

My Google Analytics code is:

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

    gtag('config', 'UA-119899800-1');
</script>

Google AdWords gives me the same code like:

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

    gtag('config', 'AW-796207283');
</script>

Where & how to locate those code together?

like image 292
Naf Rifat Avatar asked Jul 23 '18 19:07

Naf Rifat


People also ask

Is GTAG the same as Google Analytics?

They are totally two different things that serve two very different purposes. Google Tag Manager lets you manage various Javascript tracking codes (also known as Tags) on your website. Google Analytics tracking code is one of those tags.

What is the difference between GTAG js and Analytics js?

Unlike analytics. js, gtag. js doesn't use trackers to send data to Google Analytics. It sends data to Google Analytics properties identified by their IDs set by the config command.

Can I use both ga4 and UA?

By dual tagging you can keep your Universal Analytics implementation in place while you build out your Google Analytics 4 implementation.


1 Answers

You should merge codes in this way:

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

    gtag('config', 'UA-119899800-1');
    gtag('config', 'AW-796207283');
</script>

and insert it in <head> of pages you need.

https://support.google.com/google-ads/answer/7548399?hl=en

like image 182
zborovskaya Avatar answered Sep 22 '22 12:09

zborovskaya