forked from alphagov/tech-docs-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TRG-317: Provide support for Google Tag Manager
This is a cherry-pick of 63b2a30 from grahampaulcook/tech-docs-gem which introduces support for Google Tag Manager. A pull request has been raised to include this change: alphagov#187 however GDS have not yet picked it up, so we're pulling it in here for use at HMRC in the meantime.
- Loading branch information
1 parent
1b3ae4c
commit d0cd672
Showing
3 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %> | ||
<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','<%= config[:tech_docs][:gtm_id] %>'); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %> | ||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= config[:tech_docs][:gtm_id] %>" | ||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters