Implementing Fragment URL with Google Tag Manager

Modified on Thu, 07 Mar 2024 at 01:03 PM

Use Case


As a corporate, or as a marketing team, when you spend money on a sponsored campaign to drive pet owners to your website and to book an appointment, you want to be able to track that user, through to a completed booking, on your website.


Solution


The Vetstoria widgets, and floating widgets, which are integrated to your website, can provide fragment urls, which details the booking step/stage, to the host websites page url. 

This makes it easy, and reliable, for web admins and marketeers to implement tracking of these stages.


As these events are generated by the host website, this ensures that the user can remain attributed to any source campaign.


See ‘User Tracking and Ad Attribution with Fragment URL’ article for more information on how to configure the Vetstoria part of this.


Tracking Setup


Note: that this is a suggested set up. However, there are other methods for tracking changes to the URL, and if you are using a platform other than Google Analytics and Google Tag Manager, then you may need to research how to capture these URL changes.


Google Tag Manager

The following is configured within GTM, and assumes you are using GTM to manage GA on your website.
It also assumes you have a level of understanding of GTM.

Variables

Firstly, ensure you have Variable ‘New History Change’ enabled.

  1. Click on ‘Variables

  2. Within ‘Built-In Variables’, look for 'New History Fragment.

  3. If not visible, you will need to configure this.

    1. Click Configure

    2. Scroll down to the ‘History Section

    3. Tick ‘New History Fragment

    4. Close this section.



Trigger

Now create the trigger.

  1. Click Triggers

  2. Click New

  3. Provide a name; ‘Vetstoria History Change

  4. Click in the Trigger Configuration window to begin setup

    1. Choose Trigger type: ‘History Change

    2. This trigger fires on ‘Some History Changes

    3. Fire this trigger when an event occurs and all of these conditions are true

      1. URL Fragment <> Contains <> vs-

    4. Click Save


Note: we are using the consistent prefix in the fragment url of ‘vs-’. this will ensure you pick up both widget and floating button booking interactions.



Tags

Now, add the Tag, which will generate the ‘Event’ based on the Fragment URL

  1. Click on Tags

  2. Click New

  3. Provide a Name; Vetstoria Booking Events

  4. click in the Tag Configuration section on 'Choose a tag type to begin setup…

    1. Select Google Analytics: GA4 Event

    2. Select your Configuration Tag, or manually set your ID

    3. Set the Event Name; suggest: Vetstoria | {{New History Fragment}}   (This will add the step name to the event, creating an event for each step.

  5. Click in the Triggering section on ‘Choose a trigger to make this tag fire…’

    1. Select ‘Vetstoria History Change

    2. Click Save



Publish Changes

Now publish your changes, and you should start collecting event data.


Note: It may take up to 24hrs for Google Analytics to start processing and identifying events.


Google Analytics

You’ll want to consider your conversion events in Google and any reports you may want to track.


Please also note that the Vetstoria booking flow is not linear, and users can go backwards and forwards, so it is not uncommon to see counts which appear higher than expected. 



Conversion Events

Once you start to capture events, you can then set the the two ‘completed’ steps as your conversion events.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article