Google Analytics 4 (GA4): Setup on a Practice Web-Plugin Follow

What it does?

Third party tracking via Google Analytics allows you to track Healthengine Web-Plugin bookings from their originating traffic source or campaign (for example Google Ads) within your own Google Analytics 4 account. This solution ensures patient data is protected.

Requirements checklist?

The following steps are required to ensure that Google Analytics Web-Plugin bookings will track correctly. This document will go through these requirements further in the sections below.

  1. Provide healthengine’s Support team with your Google Analytics 4 IDs.
  2. Modify your Google Analytics code on your website to enable cross-domain tracking.
  3. Set up cross-domain measurement via GA4 Admin
  4. Add healthengine.com.au as a unwanted referral in your GA account.
  5. Set up custom dimensions to view additional event parameters (optional)
  6. Set up conversion by marking event (optional).
  7. Link Google Analytics & Google Ads (optional).


Web-Plugin Google Analytics Setup

Provide healthengine support with your Google Analytics 4 ID

In order to send the data into your Google Analytics account, we will need to be provided
with your Google Analytics IDs for each practice location you want to track healthengine
Web-Plugin bookings in. The Google Analytics 4 ID should be similar to the format of G-AB12CDE3FG.


If you have one of the older Google Analytics IDs that start with “UA-” for Universal
Analytics, and don’t already have a GA4 account, you will need to migrate to GA4. Please
see this article for further details.

To find your Google tag ID (which usually starts with "G-"), do the following

  1. Sign in to your Google Analytics account.
  2. In Admin, under Data collection and modification, click Data streams
  3. Click the data stream.
Don't see a Data streams option in the Property column? You have a Universal Analytics property instead of a GA4 property.

    4. Find the measurement ID in the first row of the stream details.

A screenshot of a computer

Description automatically generated

Modify your Google Analytics code on your website

In order to activate cross-domain tracking for your Google Analytics account between your
practice’s website and healthengine, the on-page Google Analytics code will need to be
modified. This allows your website to transfer the visitors unique ID that Google Analytics
uses to ensure that they are seen as 1 unique visitor and not 2.

 

PLEASE NOTE THE FOLLOWING IS CURRENTLY NOT SUPPORTED:

  • Healthengine do not currently support the ability of cross-domain for clients using the
    Google Tag Manager method to implement their Google Analytics tracking on their own
    website. The only supported method is the one detailed below.
  • The “advanced button” widget option currently doesn’t support GA4’s cross domain
    tracking.


To implement:

1. Add the following code on your website immediately after the openingHTML tag on every page that contains the Healthengine widget replacing the highlighted ‘YOUR-GA4-ID’ with your own Google Analytics 4 ID:


<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR-GA-ID"></script>
<script>
  const gaCode = 'YOUR-GA-ID';

  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', gaCode, {
    linker: { domains: ["healthengine.com.au"] }
  });

  function postData(node) {
    gtag('get', gaCode, 'client_id', client_id => {
      gtag('get', gaCode, 'session_id', session_id => {
        node.contentWindow.postMessage(
          { 'clientId': client_id, 'sessionId': session_id },
          "https://healthengine.com.au/"
        );
      });
    });
  }

  var observer = new MutationObserver((mutations) => {
      mutations.forEach((mutation) => {
        if (mutation.type !== 'childList') return;

        for (var i = 0; i < mutation.addedNodes.length; i++) {
          var node = mutation.addedNodes[0];

          // exclude non-elements (nodes without className or id)
          if (node.nodeType !== 1) { return; }

          var className = node.getAttribute('class');

          if ((className !== null && className.includes('he-webplugin-popup-')) || node.id.includes('he-webplugin-')) {
            const iframe = node.querySelector('iframe');

            if (iframe !== undefined && iframe !== null) {
              iframe.onload = () => postData(iframe);
            }
          }
        }
      });
  });

  observer.observe(document, { childList: true, subtree: true });
</script>

 

Once implemented the healthengine web-plugin booking complete URLs will start to be tracked within the Google Analytics Pages report as well as the Events report with the category of “healthengine”, the action of  “OBS Webplugin Booking Complete” and the label that contains your healthengine practice ID following by the practice name (e.g. 12345 – Perth Medical Centre). Please continue reading to continue setup.

 

Set up cross-domain measurement via GA4 Admin

You need the Editor role to set up cross-domain measurement.

PLEASE NOTE:

Check your tag (e.g. the Google tag on each of your HTML pages) for each domain that you want to include in your cross-domain measurement. The tag on each page must use the same tag ID (i.e., the same "G-" ID) from the same web data stream.
  1. In Admin, under Data collection and modification, click Data streams.
  2. Click Web, then click a web data stream.
  3. In the web stream details, click Configure tag settings (at the bottom).
  4. In the Settings section, click Configure your domains.
  5. If you use the same Google tag across domains, they are automatically detected and show up in the Recommendations section. To accept a recommendation, click Add.
    To manually add a domain, click Add condition under Include domains that match the following conditions:
    • Choose the match type of “Contains”
    • Under Domain, enter healthengine.com.au
    • Repeat to add your own domain as another condition.
  6. Click Save.

A screenshot of a computer

Description automatically generated

Add Healthengine as an unwanted referral

When a user journey crosses from your website domain to the healthengine.com.au domain, Google Analytics interprets that as the user having been referred by your domain to healthengine.com.au, and Google Analytics creates a new session. If you want to be able to measure a single session across multiple domains, you need to list your tracked domains to the unwanted referral list. This is required to see the original traffic source (for example a Google Ads campaign) that resulted in a booking via the web-plugin.

To add healthengine.com.au as an unwanted referral, follow these steps. You will need the editor role in GA4 to do this:

  1. In Admin, under Data collection and modification, click Data streams.
  2. Click Web and then click a web data stream.
  3. In the web stream details, click Configure tag settings (at the bottom).
  4. In the Settings section, click Show all to see all available settings.
  5. Click List unwanted referrals.
  6. Under Include referrals that match ANY of the following conditions:
    • Choose the “Referral domain contains” match type.
    • Under Domain, enter healthengine.com.au.
  7. Click Save.

A screenshot of a web page

Description automatically generated with medium confidence


Click here for more info.

Set up custom dimensions for event parameters (optional) 

The “OBS Webplugin Booking Complete” event also sends through additional event parameters which you can capture in GA4 if you wish.

The current set of event parameters sent through are as follows:

Event parameter Scope Description
practice_name Event The name of the practice that was booked
practice_id Event The healthengine ID for the practice that was booked
specialty Event The specialty the booking was made for
payment_method Event The payment method used for the booking (if applicable)
value Event The revenue amount (if applicable)

 

To set these up and have this data flow into your events report:

 

  1. In Google Analytics, click Admin.
  2. Make sure you are in the correct account and property.
  3. In Admin, under Data display, click Custom definitions.
  4. In the Custom dimensions tab, click Create custom dimensions.
  5. Complete the following information:
    1. Dimension name: Enter a unique name for the dimension.

You can't use hyphens in the name, but you can use underscores and spaces instead.

  1. Scope: Choose a scope for the custom dimension. See table above.
  2. Description: Enter a memorable description for the custom dimension.
  3. Event parameter/User property: Choose the source of data. See table above.
  4. Click Save.

You will see a value of (not set) for a custom dimension in the first 48 hours.


For more information on setting up custom dimensions in GA4 click here

 

Mark event as conversion (optional) 

If you would like to see Healthengine Widget Booking Completes within Google Analytics conversion report in additional to the event reports which happen automatically this requires setup within your Google Analytics account via the following steps:

  1. In Google Analytics, click Admin.
  2. Make sure you are in the correct account and property.
  3. In Admin, under Data display, click Events.
  4. In the Existing events table, for the “OBS Webplugin Booking Complete” event select the toggle under Mark as conversion.

If you can't select the toggle, you don't have the necessary permissions.

A screenshot of a computer

Description automatically generated with medium confidence

When you mark an event as a conversion, it can take some time (from a few minutes up to a few hours) for the configuration to apply to the event.

Marking an event as a conversion affects reports from time of creation. It does not change historic data. When you mark an event as a conversion, allow up to 24 hours for it to show up in standard reports. Realtime reports update sooner, at some time after a user triggers a conversion event.

 

Event setup for multi-location practices (Optional)

If you have multiple practice locations tracked under the one Google Analytics account, you can use the “create event” feature in GA4 to set up individual conversion events for each location.

For details on how to create a conversion event see https://support.google.com/analytics/answer/12844695.

 

One example of how you can set up the event for an individual practice is as per the below screenshot using the practice_id parameter that is also sent with the OBS Webplugin Booking Complete event. The practice_id for your practice can be found on the end of your healthengine profile URL after the “s”, for example:
https://healthengine.com.au/medical-centre/wa/perth/Perth-Medical-Centre/s12345

 

A screenshot of a computer

Description automatically generated with low confidence



Click here for more information on marking  events as conversions within Google Analytics 4.

 

Finding the Web Plugin Data in GA4

Once all the required steps have been set up you will be able to find the OBS Webplugin Booking Complete event data in the same Google Analytics 4 account you provided Healthengine support staff with via the following methods:

Event Report

When someone performs the action that triggers the custom “OBS Webplugin Booking Complete” event, the event will appear in the Realtime report and DebugView. You can also click the “OBS Webplugin Booking Complete” event name in the Realtime report and DebugView to see its event parameters.

When Analytics processes your custom event, you can use the following to see the event:

  • In Reports, go to the Events report.
  • In Admin, under Data display, click  Events.
  • In Explore, create a free-form exploration with the Event name dimension.

A screenshot of a computer

Description automatically generated with medium confidence

Conversion Report (If event marked as a conversion)

The Conversions report surfaces information about each conversion event.

To view the conversion report:

  1. Sign in to Google Analytics.
  2. From the left menu, select Reports .
  3. On the left, click Engagement > Conversions.


As an Editor or Administrator, you can add the report if it isn't available in the left menu.

 

 

 

 

Article is closed for comments.

Comments

Have more questions? Submit a request