Skip to content

Android demo app for Google Tag Manager + Amplitude integration

License

Notifications You must be signed in to change notification settings

amplitude/GTM-Android-Demo

Repository files navigation

Demo App - Amplitude Android SDK with Google Tag Manager

GTM integration on Android requires installing our native SDK, and then setting up GTM to trigger SDK functions via a custom function handler class that bridges GTM and our native SDKs. This demo apps is a proof of concept, with just the 3 most important functionalities implemented (logging events, setting user Id, and setting user properties) in the AmplitudeGTMHandler class. Here is our GTM setup:

User-Defined Variables (all Data Layer Variables):

  • eventProperties
  • eventType
  • userId
  • userProperties

Triggers

  • logEvent: Event equals 'logEvent'
  • setUserId: Event equals 'setUserId'
  • setUserProperties: Event equals 'setUserProperties'

Tags:

logEvent

  • type: Function Call
  • Function Name: logEvent
  • Fire on trigger: Event equals 'logEvent'
  • arguments: eventType = {{eventType}}, eventProperties = {{eventProperties}}

setUserId

  • type: Function Call
  • Function Name: setUserId
  • Fire on trigger: Event equals 'setUserId'
  • arguments: userId = {{userId}}

setUserProperties

  • type: Function Call
  • Function Name: setUserProperties
  • Fire on trigger: Event equals 'setUserProperties'
  • arguments: userProperties = {{userProperties}}

The idea is that when you want to log an event, you push a "logEvent" event to the data layer with the variables for eventType and eventProperties -> activates the logEvent trigger -> activates the logEvent tag -> calls the function logEvent in the AmplitudeGTMHandler -> calls our SDK's logEvent.

GTM Android Demo: https://github.com/amplitude/GTM-Android-Demo

Note

A lot of the other functionality from the SDK hasn't been implemented (such as logging revenue, user property operations, etc), but this proof of concept demonstrates that GTM integration with Amplitude is possible, and events are being logged with the correct user Ids. Implementing the other functionalities would follow a similar pattern.

About

Android demo app for Google Tag Manager + Amplitude integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •