Skip to main content

Setting up Google Analytics & GTM

You're in luck, Falcon support both Google Analytics and Tag Manager out of the box.

Adding & committing your credentials in a file.

The config can be added to the config files in the client/config directory. Find out more about that here

{
"googleTagManager": {
"id": [YOUR_GTM_CONTAINER_ID]
},
"googleAnalytics": {
"trackerID": [YOUR_UA_NUMBER]
}
}

Chances are you won't want to commit these into your repo. If you do, you can add them to your client/config/production.json file.

Adding your credentials on the server (advised).

It's advised you add this kind of config as a server variable.

1. Define the custom variables.

You may or may not have a client/config/custom-environment-variables.json file. If you don't, create it.

Once you've got that file you'll need to map your environment variables to the config.

client/config/custom-environment-variables.json

{
"googleTagManager": {
"id": "GTM_CODE"
},
"googleAnalytics": {
"trackerID": "GA_ID"
}
}

2. Set the environment variable values on the server

You can find a full explanation here.

  • Log into your dcloud instance.
  • Set your value dcloud env:var production GTM_CODE XXXXXXXXX

3. Finished

You should now see analytics data coming in as expected.