Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @factor/plugin-google-tag-manager with all npm packages installed. Try it out:

@factor/plugin-google-tag-manager lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("@factor/plugin-google-tag-manager/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@factor/plugin-google-tag-manager v1.8.11

This plugin adds Google Tag Manager to your Factor app.


This Factor Plugin adds Google Tag Manager to your app. Use this to add marketing plugins and most importantly, analytics.


Just add to your application dependencies:

npm add  @factor/plugin-google-tag-manager

Once you've done this Factor will automatically load this plugin. All that is needed is to add your configuration info via settings.

Customization and Settings

Config for this plugin is public only and stored in your factor-settings.js file.

// factor-settings.js
  "googleTagManager": {
    "googleTagManagerId": "GTM-XXXXXXX", // Your GTM Container ID
    "developmentMode": true // Load Tags in "development" mode (npm factor dev)
  • Development Mode - This adds the tag manager in your local development environment. This is because typically you don't want to render tags in your development environment as it could skew your data.

Using The Tag Manager Plugin

Once you've added your tag manager ID, this plugin will load the tag manager on your Factor app. From that point, most/all customization should happen inside the Google Tag Manager interface.

A Note on Tracking Route Changes

For any plugins that rely on pages to trigger an event, you'll need to add a trigger on "history change" event in the manager. This is because Factor only refreshes pages direct browser loads (for performance).

It is especially important to add this for Google Analytics to appropriately track page views and user journeys through your site.

A screenshot for how analytics should be configured:

GA History Change

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free