1

I am currently using Facebook's Customer Chat Plugin in my wordpress website.

I have been setting Google Analytics Event Tracking in my contact forms, but it seems like most people used the Customer Chat Plugin instead.

Hence I need to set Google Analytics Event Tracking in the Customer Chat Plugin as well.

Can someone assist? Cheers!

1

If you have access to the plugin source code, you can set up an event in the same way you did to your contact forms.

If not, you can use Google Tag Manager to insert the plugin and fire an event each time someone clicks the Facebook chat plugin button. For that, it's not as simple as it sounds cause this plugin uses an iframe so, first of all, you need to understand how to work with an iframe in GTM because direct approaches won't work.

Another way could be using an event listener to detect the first click which opens the chat:

focus();
var listener = window.addEventListener('blur', function() {
    if (document.activeElement === document.getElementById('iframe')) {
        // clicked
    }
    window.removeEventListener('blur', listener);
});
  • Is Facebook plugin source code transparent? I am unable to find the source code when I inspect. Google Tag Manager I have tried quite a few times on it, but as you said, it is not so straight forward due to iframe and it doesnt really work fine for me. The last one on event listener I havent tried it yet, let me explore on it and see how i can integrate it with google events. – Steph Nov 7 '18 at 2:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.