Skip to content

Commit

Permalink
add support for google tag manager
Browse files Browse the repository at this point in the history
  • Loading branch information
augchan42 committed Mar 24, 2024
1 parent 5ff3289 commit 89b1bc3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ netease_comment: false
# ba_track_id: [your track id]

# Google Tag Manager
gtm_id: "G-077BT1Q7PJ"
# gtm_id: "GTM-MCXT2HK5"

# Google Analytics
gtag_id: "G-077BT1Q7PJ"
ga_track_id: "" # Format: UA-xxxxxx-xx
ga_domain:

Expand Down
14 changes: 12 additions & 2 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,24 @@
</script>

{% if site.gtm_id %}
<!-- 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.gtm_id }}');</script>
<!-- End Google Tag Manager -->
{% endif %}

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

gtag('config', '{{ site.gtm_id }}');
gtag('config', '{{ site.gtag_id }}');
</script>
{% endif %}

Expand Down

0 comments on commit 89b1bc3

Please sign in to comment.