Add Google Tag Manager Integration (#157)

This commit is contained in:
Cagri Sarigoz 2017-01-09 07:43:53 +03:00 committed by Dean Attali
parent cef600c9fe
commit 09e037d535
5 changed files with 22 additions and 0 deletions

View File

@ -95,6 +95,9 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
# Fill in your Google Analytics ID to track your website using GA
#google_analytics: ""
# Google Tag Manager ID
#gtm: ""
# Facebook App ID
# fb_app_id: ""

6
_includes/gtm_body.html Normal file
View File

@ -0,0 +1,6 @@
{% if site.gtm %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ site.gtm }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}

9
_includes/gtm_head.html Normal file
View File

@ -0,0 +1,9 @@
{% if site.gtm %}
<!-- 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 }}');</script>
<!-- End Google Tag Manager -->
{% endif %}

View File

@ -13,6 +13,8 @@
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ site.baseurl }}/feed.xml" />
{% include gtm_head.html %}
{% if layout.common-ext-css %}
{% for css in layout.common-ext-css %}
<link rel="stylesheet" href="{{ css }}" />

View File

@ -20,6 +20,8 @@ common-js:
{% include head.html %}
<body>
{% include gtm_body.html %}
{% include nav.html %}