Skip to content

Commit

Permalink
Add Google Tag Manager Integration (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
csarigoz authored and daattali committed Jan 9, 2017
1 parent cef600c commit 09e037d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Expand Up @@ -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: ""

Expand Down
6 changes: 6 additions & 0 deletions _includes/gtm_body.html
@@ -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 changes: 9 additions & 0 deletions _includes/gtm_head.html
@@ -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 %}
2 changes: 2 additions & 0 deletions _includes/head.html
Expand Up @@ -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 }}" />
Expand Down
2 changes: 2 additions & 0 deletions _layouts/base.html
Expand Up @@ -20,6 +20,8 @@
{% include head.html %}

<body>

{% include gtm_body.html %}

{% include nav.html %}

Expand Down

0 comments on commit 09e037d

Please sign in to comment.