Integration Guide - Google Tag Manager

  • Moesif is an API analytics service. This tag enables you to track user behavior within your web app. You can also install the Moesif server agent to understand the customer journey across both your website and APIs together.

  • Google Tag Manager account is a free application which enables marketing and product teams to quickly add script tags for analytics, attribution tracking, and more without code changes.

You can use this plugin alongside a Moesif server integration to monitor server-side API traffic. This enables you to track your end-to-end customer journey and build cross-platform funnel reports like your initial sign up to first API call conversion rate.

Diagram of Moesif API monitoring and Google Tag Manager architecture

How to install

Moesif has a GTM tag in the Google Tag Manager template gallery. This installs the moesif-browser-js script without any code changes.

1. Add Tag

Log into your Google Tag Manager account and select Tags from the left menu. Then, click New from the top right like in the below picture.

Create a new Tag in Google Tag Manager

Select the Community Template Gallery blue banner and search for “Moesif API Analytics”. Then, click the blue Add to Workspace button.

2. Set Moesif Application Id

In the Tag configuration, add your Moesif application Id. Your Moesif Application Id will be displayed during the onboarding steps when signing up for Moesif.

By default, the Action Name is set to “Page View”. We recommend setting a descriptive name based on your chosen trigger in next step. For example, if the tag is fired on your Sign In Page, then set Action Name to “Sign In”

Add Moesif in Google Tag Manager

3. Choose a Trigger

Choose a trigger that will cause the tag should be fired such as “All Pages”.

Add Moesif in Google Tag Manager

For more info on how to create custom triggers, see Google’s documentation.

How to use

When the tag is fired, the tag will log a user action to Moesif.

Identifying users

You can access any of the moesif-browser-js APIs via window.moesif including identifyUser(). This can be useful since Google Tag Manager doesn’t support tracking user ids directly.

When a user logs into your app, identify the person with Moesif like so:

window.moesif.identifyUser("12345", {
  email: "john@acmeinc.com",
  firstName: "John",
  lastName: "Doe",
  title: "Software Engineer",
  salesInfo: {
    stage: "Customer",
    lifetimeValue: 24000,
    accountOwner: "mary@contoso.com",
  },
});

Event metadata

When the tag is fired, the Moesif track() method will be called with your chosen action name. The Tag also supports event metadata which is a table of key/value pairs. The tag also supports dynamic variables.

Add Moesif in Google Tag Manager