COVID-19. Revisa las medidas que puedes adoptar para responder rápidamente ante esta contingencia. Consúltalas aquí.

[wpml_language_selector_widget]
What is gtag.js and what is it for?
enfoque-data-driven-medicina

What is gtag.js and what is it for?

Global Site Tag is a library (a set of javascript variables, functions and programs that we can load on our site) designed to use the entire Google suite and third parties. It also simplifies labelling, exchange and analysis between different products.

Gtag.js makes processes much easier by keeping tags from different products in one place of code without making additional accounts or modifying settings on any separate interface. It also simplifies installation, accelerating product deployment and also gives us the opportunity to send information to different Tools by Google and third parties. This does so only once, instead of requesting different tagging.

Below we will see that the gtag.js code looks much more compact than the analytics.js code.

Google Analytics default code:

<!– Google Analytics –>
<Script>
(function(i,s,o,g,r,a,m)-i[‘GoogleAnalyticsObject’]-r;i[r]-i[r]- function()
(i[r].q-i[r].q- []).push(arguments)-,i[r].l-1*new Date();a-s.createElement(o),
m.s.getElementsByTagName(o)[0];a.async-1;a.src.g;m.parentNode.insertBefore(a,m)
•)(window,document,’script’,’https://www.google-analytics.com/analytics.js’,’ga’);

ga(‘create’, ‘UA-XXXXXXXX-X’, ‘auto’);
ga(‘send’, ‘pageview’);
</script>
<!– End Google Analytics –>

Gtag.js code:

<!– Global Site Tag (gtag.js) – Google Analytics –>
<script async src”https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID><” /script>
<Script>
 window.dataLayer ? window.dataLayer [];
 function gtag()-dataLayer.push(arguments)-;
 gtag(‘js’, new Date());

 gtag(‘config’, ‘GA_TRACKING_ID’);
</script>

With regard to migration to gtag.js there are different opinions, since depending on the characteristics of the site in question it could be more complex or easier to carry it out.

While Google assures us that the data will not be affected in case we decide to switch to gtag, it is important to have a migration plan and do an in-depth analysis that allows us to choose the simplest and most effective path for the team.

GTag map

To configure various tools on the same page, gtag.js makes it easy for us to implement in the same way and, for example, if we wanted to use Analytics and AdWords, it should only be added in the ‘config’ section within the same code:


gtag(‘config’, ‘UA-12345-6’);
gtag(‘config’, ‘AW-123456789’);


Another scenario would be the setting of a tag for conversions with different cookies, in that case, the code would look like this:


gtag(‘config’, ‘AW-GOOGLE_CONVERSION_ID_1’, conversion_cookie_prefix: aw_prefix);

gtag(‘config’, ‘AW-GOOGLE_CONVERSION_ID_2’, conversion_cookie_prefix: aw_prefix);

gtag(‘config’, ‘AW-GOOGLE_CONVERSION_ID_3’, conversion_cookie_prefix: aw_prefix);


For more examples and help about implementing gtag.js we can find information at: https://developers.google.com/

Expert consulted,

Diana Gámiz

Data Collector.

Sources:
https://www.lunametrics.com/blog/2017/12/12/what-is-gtag-google-analytics
https://developers.google.com/analytics/devguides/collection/gtagjs/
https://developers.google.com/analytics/devguides/collection/gtagjs/migration

Compartir

Share on facebook
Share on twitter
Share on linkedin
Share on print
Share on email

En Incubeta operamos bajo una marca compartida que refleja nuestro objetivo: facilitar a las empresas el "llegar al siguiente nivel de crecimiento".

Conoce más de nosotros en nuestro nuevo sitio web.

This will close in 0 seconds