In many software-as-a-service (SaaS) companies, applications are multi-tenant. This means you’ll have multiple clients sharing the same code base. However, clients will often want their own Google Analytics profiles or even their own accounts. To meet this need while also keeping things manageable in Google Tag Manager (GTM), you’ll want to store your clients’ Google Analytics (GA) Profile IDs in your database alongside their configurations. Then, once an instance of a client’s site is loaded, you can pass the client’s GA Profile ID into the GTM data layer.
First, create a macro to hold the client’s GA Profile ID in GTM:
Now create a tag instance that uses this macro for the GA Profile ID:
The last thing we’ll do in GTM is create a rule that fires our new tag after we check that the GA Profile ID is populated:
Now in our data layer on the multi-tenant application, we’ll pass the client’s GA Profile ID:
<script> var dataLayer = [{ 'gaProfileId': '[Dynamic Code to Insert client's GA Profile ID]' }]; </script>
Now you can scale your Google Analytics using Google Tag Manager! When the gaProfileID in our data layer is populated with a value starting with ‘UA-‘, then our rule will be true and our Universal GA tag will fire. This same logic applies to adding additional dynamic values that may be client-specific but useful in the client’s GA profile. If you have an aggregate profile that collects data across all clients, you can pass a unique client ID value as a custom dimension which will enable you to filter by client in your aggregate profile.
Questions or comments? Get in touch with me on Google+ or leave a comment below.
Comments on this entry are closed.
Pingback: Digital Analytics Week In Review - 16 May 2014 - Data Runs Deep()