Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
adding README
Browse files Browse the repository at this point in the history
  • Loading branch information
em0ney committed Aug 22, 2015
1 parent 2ab8106 commit e0b8aa4
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# gorillastack:iron-router-gtm

Having trouble installing google tag manager? Even worse, tracking pageviews not working because you are awesome enough to have a single page application? Hopefully this package helps you with this problem.

Similar to `reywood:iron-router-ga`, this package allows you to provide your GTM ID via `Meteor.settings` and fires virtual pageviews by sending messages to google tag manager's `dataLayer` from iron router's `onRun` hook for each route you have configured for tracking!

### Installation

#### 1. Provide your google tag manager id

Add the following to your [Meteor.settings](http://docs.meteor.com/#/full/meteor_settings)

```json
{
"public": {
"gtm": {
"id": "GTM-XXXXXX"
}
}
}
```
---

#### 2. Configure which routes to track

##### All routes

```javascript
Router.configure({
trackPageView: true
});
```
##### All routes with individual routes disabled

```javascript
Router.configure({
trackPageView: true
});

Router.route("notMe", {
trackPageView: false
});
```
##### Individual routes

```javascript

Router.route("justMe", {
trackPageView: true
});

Router.map(function() {
this.route("andMe", {
trackPageView: true
});
});
```
---

#### 3. Congfigure GTM to track virtual pageviews

This is the part that connects the URL that this package sends to GTM to whichever tags you want!

##### 3.a) Configure variable

This is where we name the variable coming from this package and give it a name that makes sense within your Google Tag Manager context. We have named the variable `virtualPageURL` on our side.

![Configure variable](https://s3-ap-southeast-2.amazonaws.com/gorillastack-random-public/configure_variable.png)

##### 3.b) Configure trigger on variable

![Configure trigger on variable](https://s3-ap-southeast-2.amazonaws.com/gorillastack-random-public/configure_trigger.png)

##### 3.c) Add trigger to any tag

![configure tag to fire on event](https://s3-ap-southeast-2.amazonaws.com/gorillastack-random-public/configure_tag_to_fire_on_event.png)

Now kick your GTM into debug mode and test whether it's firing VirtualPageview on all the pages you expect!

0 comments on commit e0b8aa4

Please sign in to comment.