Tracking Meeting Events, Setting as a Goal in Google Analytics with GTM

Highlighted
Occasional Contributor

I spent hours upon hours trying build a report that would show me visitors that landed on our website and signed up for a demo meeting. Below is my solution to track visitors that:

  1. Landed on website
  2. Clicked on sign up for demo
  3. Scheduled demo meeting

Here's my solution using GTM (Google Tag Manager):

 

1) Create a trigger using Page view, I set to all pages being it only triggers based on the listener. 

6464719563784192.png

 

2) Next, We'll create a custom HTML tag listener, apply the above trigger to this listener.

This listens for if a person creates / schedules a meeting using the HS calendar meeting feature embedded on your website.

4586410106159104.png

<script type="text/javascript">
  function isOmnidekUrls(url) {
    var omnidekUrls = [
      'https://info.omnidek.com'
     ];
    return omnidekUrls.indexOf(url) > -1;
  }

// hubspot meetings uses postMessage api to send various events
  function receiveMessage(event) {
    debugger;
   if (isOmnidekUrls(event.origin) && event.data.meetingCreated) {
         dataLayer.push({'event': 'meeetingBookSucceeded'});
   }
  
  // there is a typo in the event fired by hubspot. `meeetingBookSucceeded`
  //  is the correct attribute to watch for.
  if (isOmnidekUrls(event.origin) && event.data.meetingBookSucceeded) {
    dataLayer.push({'event': 'meetingCreated'});
    console.log('hubspot meetings: meeetingBookSucceeded event');
    	window.dataLayer.push({
      'event': 'hubspot-form-success',
      'hs-form-guid': event.data.id
    });
  }  
}

window.addEventListener('message', receiveMessage)
  

</script>

 

3) We'll create a second trigger that will fire if the above event happens.

6393614769586176.png

 

4) Now, we're going to create a virtual pageview based on an event, this step took me some time to discover. 

We create a virtual pageview if the trigger above fires. See screenshot for details

5903468739690496.png

 

As for the goal I setup in google analytics, is straight forward. Now please note I also created an event and virtual pageview for the click of our signup button to setup this goal.

5607981834829824.png

 

Now you may view this goal in a funnel visulization and also in a table report to see website visitors to demo signup conversions and more...

 

www.omnidek.com

2 Replies 2
Highlighted
Community Manager

Thanks for sharing @Omnidek!


Did my post help answer your query? Help the Community by marking it as a solution
Reply
0 Upvotes
Highlighted
Occasional Contributor

Thanks @jennysowyrda

 

I know this solution may seem technical, please reach out to me for assistance, I do not mind.

Reply
0 Upvotes