Skip to content

Commit

Permalink
adding virtualHostname dataLayer attribute to GTM, such that localhos…
Browse files Browse the repository at this point in the history
…t and other filtering can be done on VirtualPageviews.
  • Loading branch information
em0ney committed Aug 25, 2016
1 parent 93bc4e5 commit a603378
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion lib/client/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -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: '[email protected]:GorillaStack/meteor-iron-router-gtm.git',
documentation: 'README.md'
Expand Down

0 comments on commit a603378

Please sign in to comment.