Google Analytics with Google Tag Manager (GTM)

Learn how to segment app users in your Google Analytics account
Turn your website into an app in 60 seconds!
Preview My App
Jack & Jones' desktop website and mobile app.

Track Canvas page views via Google Analytics

You can track your app users via Google Analytics and Google Tag manager.

In order to do this, you will need to create a custom dimension in Google Analytics, and create a new tag that checks the user-agent in Google Tag Manager.

Even though this sounds simple enough, there are quite a few things you need to do on both platforms to achieve the desired result.

If you have a popular website, with many users, we’d recommend asking a developer to help you with this, to avoid issues with your Analytics metrics.

Before we start, keep in mind that MobiLoud Canvas relies on your website for all the content, when a page of your website is displayed in the app, we are simply performing an HTTPS request to it. For that reason, we are going to use the same Google Analytics Property that you use for your website, and it should look like this:

Notion Image

Let’s get started!

Step 1 - Create a custom dimension in Google Analytics

On the left sidebar, open the "Admin" area by clicking the "Gear" icon on the very bottom:

Now select “Custom Definitions” under the "Property" column:

Click the “Create custom dimensions” button on the right side of the screen:

Notion Image

A form will appear on the right side of your screen, and you must fill the fields as follows:

  • Dimension name: app_user
  • Scope: User
  • Description: can be empty
  • Event parameter: app_user

It is extremely important to use the values above, for consistency. Later, once you have a clear understanding of how the setup works, you can adjust it accordingly if you’d like to. Your form should look like this:

Notion Image

Step 2 - Copy your Web Steam Measurement ID

Before leaving your Google Analytics Dashboard, go to “Admin” on the left sidebar:

Notion Image

Select “Data Streams”:

Notion Image

Select your website’s data stream:

Notion Image

Click the “Copy” button on your Measurement ID, and save the number somewhere on your computer, you will need it later:

Notion Image

Step 3 - Setup your variable in Google Tag Manager

Let’s move to Google Tag Manager now, you can click on your website name in the top left area:

Notion Image

On the window that will appear, move to the “Google Tag Manager” icon, and select your website:

Notion Image

You are now in the “Tag Manager” area, click the “Variables” link on the left sidebar:

Notion Image

Then click the “New” button on the right side:

Notion Image

Click on the large block that will appear to start configuring your Variable:

Notion Image

Now pick “Custom Javascript” as the variable type:

Notion Image

You will then be requested to provide a piece of Javascript code, as follows:

Notion Image

Here is the code so you can easily copy and paste it:

function() {
  var isApp = navigator.userAgent.toLowerCase().indexOf('canvas') > -1;
  if (isApp) {
    return "canvas";
  } else {
    return "browser";
  }
}

Make sure to save your variable:

Notion Image

Step 4 - Create your tag in Google Tag Manager

With your variable created, it is time to create your tag. Click “Tags” on the left sidebar:

Notion Image

Click the “New” button on the right side:

Notion Image

Click the “Tag configuration” block:

Notion Image

Pick “Google Analytics: GA4 Configuration” as the tag type:

Notion Image

Fill in the “Measurement ID” field with the value you previously copied from your Google Analytics account:

Notion Image

Expand the “User Properties” area and fill the “Property Name” field with “app_user”:

Notion Image

On the “Value” field, click the small brick icon and pick the variable you created in the previous step:

Notion Image
Notion Image

Now click the “Triggering” block:

Notion Image

Select “All pages”:

Notion Image

Click “Save”:

Notion Image

Step 5 - Submit your tags and install Google Tag Manager on your website

The first step now is to submit everything you created, so it goes live into production, you can do that by clicking the “Submit” button on the right side of the screen:

Notion Image

Google will ask you for a few confirmations, but just click the “Publish” button until your changes are submitted.

If you never used Google Tag Manager before, you might need to add its code to your website, you can find all the details on how to implement the code to your website by clicking on your Tag Manager ID, here:

Notion Image

Step 6 - Reporting

Congratulations, if you followed all steps until this point, you should now be tracking all users that are viewing your website through the app.

Note that it might take up to 48 hours until you start seeing user data being tracked with the newly created custom dimension, so give it some time before you look into the reports.

To use your newly created custom dimension, go to your Google Analytics Dashboard, then Reports:

Notion Image

Select the type of report you want to see, in this case, we are using “Pages and screens”:

Notion Image

On the report parameters, click the small “+” icon:

Notion Image

Now pick your “app_user” custom dimension to start showing the data:

Notion Image

You will now see each page/screen view split between the canvas users and browser users:

Notion Image

Launch your brand's mobile app with a team of experts by your side.

Our team holds your hand through every step of the process to make building an app a no-brainer.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
  • Preview your app yourself or get a live demo on a call.
  • Learn about our platform and process to help you launch with minimal work required.
  • Risk free - 100% app approval guaranteed or your money back.
Only and Bestseller's iOS and Android apps.
Thank you! We'll be in touch within 48 hours :)
Oops! Something went wrong while submitting the form.
Chat icon.