Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add google tag manager #104

Merged
merged 2 commits into from Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>