Skip to content

Commit

Permalink
add GTM tracking code
Browse files Browse the repository at this point in the history
- add GTM tracking code to start of <head>
- reorganize <head> partials to give more flexibility for placing fragments
- link to stylesheet directly below <title> in <head>
  • Loading branch information
mojavelinux committed Sep 13, 2018
1 parent 34640de commit 6514e2a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/layouts/404.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{> head-first}}
<title>{{{detag (or page.title 'Page Not Found')}}}{{#if site.title}} | {{{site.title}}}{{/if}}</title>
{{> head}}
{{> head-last}}
</head>
<body class="status-404">
{{> header}}
Expand Down
12 changes: 2 additions & 10 deletions src/layouts/default.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{{> head-redirect}}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{> head-first}}
<title>{{{detag (or page.title 'Untitled')}}}{{#if site.title}} | {{{site.title}}}{{/if}}</title>
{{#if page.canonicalUrl}}
<link rel="canonical" href="{{page.canonicalUrl}}">
{{/if}}
{{#if page.description}}
<meta name="description" content="{{page.description}}">
{{/if}}
{{#if page.keywords}}
<meta name="keywords" content="{{page.keywords}}">
{{/if}}
{{> head}}
{{> head-last}}
</head>
<body class="article">
{{> header}}
Expand Down
12 changes: 2 additions & 10 deletions src/layouts/home.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{{> head-redirect}}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{> head-first}}
<title>Couchbase Documentation</title>
{{#if site.url}}
<link rel="canonical" href="{{site.url}}">
{{/if}}
{{#if page.description}}
<meta name="description" content="{{page.description}}">
{{/if}}
{{#if page.keywords}}
<meta name="keywords" content="{{page.keywords}}">
{{/if}}
{{> head}}
{{> head-last}}
</head>
<body class="home">
{{> header}}
Expand Down
8 changes: 8 additions & 0 deletions src/partials/head-first.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<meta charset="utf-8">
{{#if (eq env.FORCE_HTTPS 'true')}}
<script>(function(l,p){if(l.protocol!==p)l.protocol=p})(location,'https:')</script>
{{/if}}
{{#if site.keys.googleAnalytics}}
<script>(function(w,d,s,l,i){(w[l]=w[l]||[]).push({'gtm.start':+new Date(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],g=d.createElement(s);g.async=true;g.src='https://www.googletagmanager.com/gtm.js?id='+i;f.parentNode.insertBefore(g,f)})(window,document,'script','dataLayer','{{site.keys.googleAnalytics}}')</script>
{{/if}}
<meta name="viewport" content="width=device-width,initial-scale=1.0">
3 changes: 3 additions & 0 deletions src/partials/head-last.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<link rel="stylesheet" href="{{uiRootPath}}/css/site.css">
{{> head-meta}}
{{> head-scripts}}
7 changes: 6 additions & 1 deletion src/partials/head-meta.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{{#if page.component}}
{{#if page.description}}
<meta name="description" content="{{page.description}}">
{{/if}}
{{#if page.keywords}}
<meta name="keywords" content="{{page.keywords}}">
{{/if}}
<link rel="schema.dcterms" href="https://purl.org/dc/terms/">
<meta name="dcterms.subject" content="{{page.component.name}}">
<meta name="dcterms.identifier" content="{{page.version}}">
{{/if}}
{{#if (or antoraVersion site.antoraVersion)}}
<meta name="generator" content="Antora {{or antoraVersion site.antoraVersion}}">
{{/if}}
<link rel="stylesheet" href="{{uiRootPath}}/css/site.css">
<link rel="icon" href="{{uiRootPath}}/img/favicon.ico" type="image/x-icon">
3 changes: 0 additions & 3 deletions src/partials/head-redirect.hbs

This file was deleted.

6 changes: 0 additions & 6 deletions src/partials/head-scripts.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
{{#if site.keys.googleAnalytics}}
{{#with site.keys.googleAnalytics}}
<script async src="https://www.googletagmanager.com/gtag/js?id={{this}}"></script>
<script>dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)};gtag('js',new Date());gtag('config','{{this}}')</script>
{{/with}}
{{/if}}
2 changes: 0 additions & 2 deletions src/partials/head.hbs

This file was deleted.

0 comments on commit 6514e2a

Please sign in to comment.