Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 2.71 KB

README.md

File metadata and controls

50 lines (38 loc) · 2.71 KB

Demo App - Amplitude iOS SDK with Google Tag Manager

GTM integration on iOS 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.

Note, if you are running this demo app locally, you will need to install Cocoapods and run pod install in the base directory, otherwise you will need to install our SDK manually by following the Setup instructions steps 2-4.

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 iOS Demo: https://github.com/amplitude/GTM-iOS-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.