Skip to content

Commit f681a6d

Browse files
Merge pull request #1 from GSA/add-gtm
Add GTM container
2 parents 12fe2c1 + 6b5ce6d commit f681a6d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.env.development.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
GOOGLE_TAG_MANAGER_ACCOUNT_ID=YOUR-GTM-ACCOUNT-ID-HERE
2+
TOUCHPOINTS_GTM_CONTAINER_ID=YOUR-APP'S-GTM-CONTAINER-ID-HERE

app/views/layouts/application.html.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@
99

1010
<%= stylesheet_link_tag 'application', media: 'all' %>
1111
<%= javascript_include_tag 'application' %>
12+
<!-- Google Tag Manager -->
13+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
14+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
15+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
16+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
17+
})(window,document,'script','dataLayer','<%= ENV.fetch("TOUCHPOINTS_GTM_CONTAINER_ID") %>');</script>
18+
<!-- End Google Tag Manager -->
1219
</head>
1320

1421
<body>
22+
<!-- Google Tag Manager (noscript) -->
23+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= ENV.fetch("TOUCHPOINTS_GTM_CONTAINER_ID") %>"
24+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
25+
<!-- End Google Tag Manager (noscript) -->
1526
<%= render 'components/header' %>
1627
<div class="usa-grid">
1728
<div class="usa-width-full">

0 commit comments

Comments
 (0)