diff options
author | Srinivas Narayanan <srininara@gmail.com> | 2022-10-13 12:03:13 +0530 |
---|---|---|
committer | Srinivas Narayanan <srininara@gmail.com> | 2022-10-13 12:03:13 +0530 |
commit | 14ac9be18a3d0a88e581c7299a15f31bc77d85b9 (patch) | |
tree | 3f0379eb8eaceae24c820f3d6fe437f58eccdaac | |
parent | 67f61789a9c50e8a6f895da9ac9c532e2eb650cb (diff) | |
download | pelican-themes-14ac9be18a3d0a88e581c7299a15f31bc77d85b9.tar.gz |
gtag support
-rw-r--r-- | pelican-bootstrap3/templates/base.html | 3 | ||||
-rw-r--r-- | pelican-bootstrap3/templates/includes/ga.html | 26 |
2 files changed, 15 insertions, 14 deletions
diff --git a/pelican-bootstrap3/templates/base.html b/pelican-bootstrap3/templates/base.html index af2f0f9..cb673d0 100644 --- a/pelican-bootstrap3/templates/base.html +++ b/pelican-bootstrap3/templates/base.html @@ -113,6 +113,8 @@ title="{{ SITENAME }} {{ category }} ATOM Feed"/> {%- endif %} + {% include 'includes/ga.html' %} + </head> <body> @@ -232,7 +234,6 @@ {% endif %} {% include 'includes/sidebar/github-js.html' %} {% include 'includes/disqus_script.html' %} -{% include 'includes/ga.html' %} {% include 'includes/piwik.html' %} {% if 'liquid_tags.notebook' in PLUGINS %} diff --git a/pelican-bootstrap3/templates/includes/ga.html b/pelican-bootstrap3/templates/includes/ga.html index 8663e73..c0c3425 100644 --- a/pelican-bootstrap3/templates/includes/ga.html +++ b/pelican-bootstrap3/templates/includes/ga.html @@ -1,21 +1,21 @@ {% if GOOGLE_ANALYTICS %} <!-- Google Analytics --> - <script type="text/javascript"> - - var _gaq = _gaq || []; - _gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS }}']); - _gaq.push(['_trackPageview']); + <script async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLE_ANALYTICS }}"></script> + <script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); - (function () { - var ga = document.createElement('script'); - ga.type = 'text/javascript'; - ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(ga, s); - })(); + gtag('config', {{ GOOGLE_ANALYTICS }}); </script> <!-- End Google Analytics Code --> + <!-- Google Tag Manager --> + <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','{{ GA_GTM_CONTAINER_ID }}');</script> + <!-- End Google Tag Manager --> {% endif %} {% if GOOGLE_ANALYTICS_UNIVERSAL %} <!-- Google Analytics Universal --> |