From a6033784fb25e840eddee1594dcaff3284cbf0a8 Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Thu, 25 Aug 2016 12:28:29 +1000 Subject: [PATCH] adding virtualHostname dataLayer attribute to GTM, such that localhost and other filtering can be done on VirtualPageviews. --- README.md | 2 +- lib/client/router.js | 3 ++- package.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 743b892..0b325e4 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Now kick your GTM into debug mode and test whether it's firing VirtualPageview o #### 4. Configure Google Analytics/Supported Plugins to pass the virtualPageURL -Within your tag configuration, select 'more settings' and configure your 'fields to set', such that the `location` variable is set with your `virtualPageUrl`. +Within your tag configuration, select 'more settings' and configure your 'fields to set', such that the `location` variable is set with your `virtualPageUrl`. We also export a variable `virtualHostname` with the same event, such that you can filter or set up exceptions based on the hostname (e.g. filter out localhost). ![configure fields to set](https://s3-ap-southeast-2.amazonaws.com/gorillastack-random-public/fields_to_set.png) diff --git a/lib/client/router.js b/lib/client/router.js index b2b9ce7..ba095cf 100644 --- a/lib/client/router.js +++ b/lib/client/router.js @@ -3,7 +3,8 @@ Router.onRun(function () { gtmBulldozer.bulldoze(); dataLayer.push({ event: 'VirtualPageview', - virtualPageURL: this.url + virtualPageURL: this.url, + virtualHostname: window.location.hostname }); } this.next(); diff --git a/package.js b/package.js index ce8ed6e..a828270 100644 --- a/package.js +++ b/package.js @@ -1,6 +1,6 @@ Package.describe({ name: 'gorillastack:iron-router-gtm', - version: '0.2.0', + version: '0.3.0', summary: 'Install google tag manager and track pageviews in iron-router', git: 'git@github.com:GorillaStack/meteor-iron-router-gtm.git', documentation: 'README.md'