Implementing HubBox via Google Tag Manager (GTM)

Introduction: Using GTM for HubBox Tag Implementation

This guide explains how to implement the HubBox pickup point selection functionality on your website using Google Tag Manager (GTM). For more information on HubBox's Tag, please visit the Tag documentation directly.

This approach is primarily intended for websites or ecommerce platforms where you do not have direct access to modify the checkout page code or add custom scripts directly through the platform's backend. GTM allows you to inject the necessary HubBox JavaScript ("Tag") onto the page indirectly.

How it Works

You will configure GTM to insert and execute the HubBox Tag script specifically on your checkout pages. When triggered correctly, this script will load the HubBox interface (e.g., the pickup point selection map/widget) allowing customers to choose a pickup location.

Prerequisites:

  1. Active GTM Container: You must have a Google Tag Manager container correctly installed and firing on all relevant pages of your website, including your entire checkout process.
  2. GTM Access: You need sufficient permissions within your GTM account to create tags and triggers and publish changes.
  3. HubBox Tag Script: You need the specific HubBox JavaScript Tag snippet provided to you by the HubBox team (e.g., by your Integrations Manager).

Important Considerations & Caveats:

Step 1: Obtain Your HubBox Tag Script

Before starting in GTM, ensure you have the correct HubBox Tag script. This unique JavaScript snippet will be provided by HubBox (typically by your Integrations Manager).

This script contains the necessary code to initialize the HubBox service, display the pickup point selection interface within your checkout, and handle the selection process. Keep this script readily available for Step 3.

Step 2: Create the GTM Trigger (When/Where to Load HubBox)

The trigger tells GTM when and on which pages to execute the HubBox Tag script. The goal is usually to fire it on your checkout page(s) once the main page elements are loaded.

Using the "Window Loaded" Trigger (Common Method):

This trigger waits until the browser has finished loading the entire page content, including scripts and images. This often ensures the page elements HubBox needs to interact with are available.

  1. Navigate to your GTM Workspace and click Triggers in the left menu.
  2. Click the New button.
  3. Give your trigger a descriptive name, e.g., HubBox - Trigger - Checkout Window Loaded.
  4. Click the Trigger Configuration box and select the Window Loaded trigger type. gtm-trigger
  5. Under This trigger fires on, select the Some Window Loaded Events radio button. gtm-window-loaded
  6. Configure the condition to target your checkout page(s). A common approach is:
    • Select Page URL from the first dropdown.
    • Select contains (or matches RegEx, starts with, etc., depending on your URL structure) from the second dropdown.
    • Enter a unique part of your checkout page URL in the text box (e.g., checkout, /store/checkout, order/shipping). Inspect your website's checkout URLs carefully to find a reliable identifier. gtm-window-loaded-events
  7. Click Save.

Important Notes on Triggers:

Step 3: Create the GTM Tag (Injecting the HubBox Script)

The tag is the container within GTM that holds your HubBox JavaScript and links it to the trigger.

  1. Click Tags in the left menu, then click the New button.
  2. Give your tag a descriptive name, e.g., HubBox - Custom HTML - Load Widget.
  3. Click the "Tag Configuration" box and choose the Custom HTML tag type. gtm-creating-tag
  4. Carefully paste the entire HubBox Tag script (provided to you by HubBox in Step 1) into the HTML text area. Ensure you copy and paste it exactly as provided.
  5. Click the Triggering box below the HTML section.
  6. Select the trigger you created in Step 2 (e.g., HubBox - Trigger - Checkout Window Loaded).
  7. Click Save.

Step 4: Previewing, Testing, and Publishing

This is a critical step, especially when injecting scripts into a checkout via GTM.

  1. Enable Preview Mode: In the top right of your GTM workspace, click the Preview button. Enter the URL of your website (usually the homepage) and click "Connect". A new browser tab/window connected to GTM Preview mode will open, and you should see the GTM debug panel at the bottom.
  2. Navigate and Test:
    • Navigate through your website to the checkout page(s) where you configured the trigger to fire.
    • In the GTM debug panel, select the "Window Loaded" (or your chosen trigger event) on the left. Check if your HubBox tag (HubBox - Custom HTML - Load Widget) appears under the "Tags Fired" section.
    • Verify Functionality: Does the HubBox pickup selection UI appear correctly on the page? Does it appear without excessive delay or causing other page elements to jump ("flicker")?
    • Test Interactions: Go through the process of selecting a pickup point. Does it work smoothly? Does the shipping address update correctly upon selection (as described in "Expected Outcome" below)?
    • Check for Errors: Open your browser's Developer Console (usually F12 key). Look for any JavaScript errors, especially any originating from the HubBox Tag script or GTM itself.
    • Cross-Browser/Device Testing: Repeat the functional tests on major browsers (Chrome, Firefox, Safari, Edge) and different devices (desktop, tablet, mobile) using GTM's preview sharing feature or by publishing to a test environment if available.
    • Conflict Testing: Test with other potential checkout actions, different payment methods, guest vs. logged-in checkout, etc., to ensure no conflicts with other scripts or GTM tags.
  3. Iterate if Needed: If the tag doesn't fire, double-check your trigger conditions against the actual page URL/events. If the HubBox UI doesn't work correctly or causes errors, double-check the script was pasted exactly and contact HubBox support. You may need to adjust trigger types or timing for complex sites.
  4. Publish Changes: Only after you are fully satisfied with testing in Preview mode, go back to your GTM workspace, click the Submit button. Provide a descriptive name and description for your changes (e.g., "Added HubBox Tag for Click & Collect") and click Publish. The HubBox Tag will now be live for all users.

Expected Outcome

Once the HubBox Tag is correctly implemented via GTM and published:

Troubleshooting & Support

If you encounter persistent issues during setup or testing using GTM, please contact the HubBox Client Support team at clientsupport@hub-box.com for assistance, providing details about your GTM setup (tag, trigger configuration) and any errors observed.