Search code examples
androidiosgoogle-tag-managerevent-trackingintercom

How to set up event tracking in Intercom through Google Tag Manager


In our project we are already using Google Tag Manager for Google Analytic's, with that now we have to send events to Intercom also, How to set up event tracking in Intercom using Google Tag Manager instead of writing code in Project,Anyone have experience doing this with Intercom, can some one guide me in this

Note :: am Using GTM Mobile container Android v4


Solution

  • 1. Define the function call tag in the GTM web interface with arguments as you required based on the Triggers please find attached images for function call tag Configuration

    enter image description here enter image description here

    2. In Your Project Code Create a class IntercomActionEventsFunctionTagHandler which will implements FunctionCallTagCallback public class IntercomActionEventsFunctionTagHandler implements Container.FunctionCallTagCallback { @Override public void execute(final String functionName, final Map eventDataMap) { } }

    3. Register Your FunctionCallTagCallBack On load of the ContainerHolder containerHolder.getContainer().registerFunctionCallTagCallback("ActionEventsFunction", new IntercomActionEventsFunctionTagHandler());

    4. When Ever Event Get triggered Then automatically your HandlerCode will get Triggers then finally inside execute method Log Your KeyPairs map to the Intercom Intercom.client().logEvent("ActionEvents", eventDataMap);

    5. Your Final class will be like as follows public class IntercomActionEventsFunctionTagHandler implements Container.FunctionCallTagCallback { @Override public void execute(final String functionName, final Map eventDataMap) { Intercom.client().logEvent("ActionEvents", eventDataMap); } }

    6. Don't forgot to create a version or publish GTM Configuration changes in web interface