Skip to content

Commit

Permalink
Merge pull request #104 from zhabinka/branch-add-gtm
Browse files Browse the repository at this point in the history
add google tag manager
  • Loading branch information
fey committed Nov 29, 2019
2 parents 7d2d80d + b339566 commit b434245
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
Expand Up @@ -49,3 +49,5 @@ GITHUB_URL_REDIRECT=

SPARKPOST_SECRET=
ROLLBAR_TOKEN=

GOOGLE_TAG_MANAGER_KEY=
6 changes: 6 additions & 0 deletions resources/views/layouts/app.blade.php
Expand Up @@ -13,6 +13,9 @@

<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
@if (env('APP_ENV') == 'production')
@include('layouts.deps._gtm_head')
@endif

<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
Expand All @@ -23,6 +26,9 @@
</head>

<body class="d-flex flex-column">
@if (env('APP_ENV') == 'production')
@include('layouts.deps._gtm_body')
@endif
<div class="d-flex flex-column min-vh-100">
@include('layouts._nav')
<main class="my-5">
Expand Down
1 change: 1 addition & 0 deletions resources/views/layouts/deps/_gtm_body.blade.php
@@ -0,0 +1 @@
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ env('GOOGLE_TAG_MANAGER_KEY') }}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
5 changes: 5 additions & 0 deletions resources/views/layouts/deps/_gtm_head.blade.php
@@ -0,0 +1,5 @@
<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','{{ env('GOOGLE_TAG_MANAGER_KEY') }}');</script>

0 comments on commit b434245

Please sign in to comment.