dillonzq / LoveIt

❤️A clean, elegant but advanced blog theme for Hugo 一个简洁、优雅且高效的 Hugo 主题
https://hugoloveit.com
MIT License
3.37k stars 1.07k forks source link

[FEATURE] Google Tag Manager #406

Open mwolfaardt opened 4 years ago

mwolfaardt commented 4 years ago

Describe the feature you want 描述你的功能需求

Use google tag manager https://support.google.com/tagmanager/answer/6102821?hl=en&ref_topic=3441530

mwolfaardt commented 4 years ago

Any update?

khusika commented 4 years ago

Any update?

You can use Google Tag Manager by define the id under params.analytics.google

mwolfaardt commented 3 years ago

Any update?

You can use Google Tag Manager by define the id under params.analytics.google

I had a look, and the script uses google analytics javascript, and not the Google Tag Mangager script

<!-- 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','SITE_ID');</script>
<!-- End Google Tag Manager -->
khusika commented 3 years ago

Any update?

You can use Google Tag Manager by define the id under params.analytics.google

I had a look, and the script uses google analytics javascript, and not the Google Tag Mangager script

<!-- 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','SITE_ID');</script>
<!-- End Google Tag Manager -->

Have you tried to use Google Analytics with linked Google Tag Manager? The default template using linked GTM instead of Google Analytics see here

mwolfaardt commented 3 years ago

I have thank you, if you insert your tag id it doens't work. I believe the main difference is that Google Analytics uses https://www.googletagmanager.com/gtag/js and Google Tag Manager uses a different library https://www.googletagmanager.com/gtm.js?