Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Google Analytics using gtag.js #7

Open
hgmtnd opened this issue Apr 11, 2018 · 0 comments
Open

Add support for Google Analytics using gtag.js #7

hgmtnd opened this issue Apr 11, 2018 · 0 comments

Comments

@hgmtnd
Copy link

hgmtnd commented Apr 11, 2018

Actualmente, UFFOptimizer permite registrar su información en Google Analytics, cuando éste está agregado a las páginas por medio de analytics.js. De acuerdo a la documentación de UFFOptimizer:

<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', 'YOUR CODE', 'auto');//your code example UA-132123123-1
      _$ga('send', 'pageview');
</script>

Este método ya no es el que Google recomienda; los métodos preferidos en este momento son Global Site Tag (gtag.js) o Google Tag Manager.

El snippet de JavaScript para agregar Analytics via gtag.js es el siguiente:

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

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

Sería útil que UFFOptimizer sume soporte para gtag.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant