Install Google Tag Manager & Track Events

(Soufiane Ibenbrahim) #1

Hello,
I’m wondering if there any way to install Google tag manager script on the flows.

We would like to track specific fired events from the flow and send / record them to Google Analytics or Facebook through google tag manager.

For example, we use the flows to generate leads from web & whatsapp. A lead is a user who answer questions about his name & email. Once the user answer his email, we want to fire an event and record it.

We used to do this on “normal” web forms, when a user fill a form and hit submit, we record the event as a lead and we send it to google analytics & Facebook via google tag manager.

We don’t know if that is possible using flows.

Thanks

(Nathan Stults) #2

Hello,

If you are using a web based chatbot, then yes you can write events to Google Tag Manager. You can actually execute any arbitrary code you want client-side in your flows, whether that is writing to the data layer for GTM or showing a modal dialog or anything else.

Please see the Execute Javascript task in our Web Actions integration: https://support.flowxo.com/article/263-web-actions#execute_javascript

Code configured this way will execute in the context of your page, so any libraries you have included or global variables (like the dataLayer or a custom JavaScript method you have defined on your page) are already present and can be interacted with.

(Soufiane Ibenbrahim) #3

Thanks Nathan,
Excuse me i still a little bit confused.

More details will help me a lot.

My first question :
Where we have to install the Google Tag Manager Script ?
On the website who host the web chatbot ? or on the Flow it self (as a javascript code)?

Second question:
How to listen on specific events in specific steps on the flow ?

Thanks

(Nathan Stults) #4

Hello,

So you install the Google Tag Manager script on the webpage that hosts the bot. Then, in the Execute JavaScript action, you can interact with those scripts. For instance, to push GTP events on to the dataLayer.

All you would need in the Flow XO Execute Javascript snippet is something like

dataLayer.push({event:'event'});

As for listening to events, you won’t actually listen to events in the flow, you’ll add an Execute Javascript task after various places in your flow where you want an event to be triggered in GTM.

So, after you successfully collect a name, you could add a Java Script task with a piece of code like

dataLayer.push({event:'name_collected'});

If that isn’t what you’re asking for I might have misunderstood your requirement.

Nathan

(Soufiane Ibenbrahim) #5

Thanks Nathan,
The first part is clear :
The GTM script needs to be installed on the webpage that hosts the bot.
I was not sure that the web bot (set up in iframe) could read & communicate with the Google tag manager script installed on the parent site.

The Second part is about to send the information from the web bot to the Google Tag Manager. Usually se use “triggers” for that… Something like when a web form is successfully submit, we take to form class as a trigger.

I understand that we have to configure those triggers from the flow side with javascripts snippets using datalayers events… we will look that way and let you know.

(Nathan Stults) #6

Yeah, GTM is usually trigger based. However, there is not any way I’m aware of to configure the Flow XO bot to influence the host page in a way that you can use the Google Tag Manager UI to set up page triggers in a way you are used to - I think the only way will be to explicitly fire custom events:

https://support.google.com/tagmanager/answer/7679219?hl=en

(Soufiane Ibenbrahim) #7

It’s much clearer now
Thank you Nathan.

Last question :
Is there any way to automatically open a web page during a conversation ?

For example :
At the end of the conversation i want to automatically redirect the user to a webpage (let’s say a thank you page) without any action from the user end.

(Nathan Stults) #8

Yes there is. In the same Web Actions integration where you find “Execute Javascript” you will also find the method “Navigate to URL” task that you can use to do just what you’re asking for.

Alternatively, if you preferred, you can navigate the user using custom Javascript in a “Execute Javascript” task.

Thanks,

Nathan

(Soufiane Ibenbrahim) #9

Works like a charm !
Thank you Nathan.

I guess there is no way to auto navigate to URL on Whatsapp ?

Thanks

(Nathan Stults) #10

Hi Soufiane,

You are correct - there is no way to auto-navigate from WhatsApp. In fact, any of the techniques from this thread, including the Google Tag Manager tasks (or anything inside the Web Actions integration) will ONLY work on the Web bot.