Website Setup (via GTM)
Learn how to implement Hardal analytics on your website using Google Tag Manager
Overview
Hardal provides a server-side analytics solution that helps you collect and process visitor data through a first-party data pipeline. This guide will walk you through implementing Hardal on your website using Google Tag Manager (GTM), which simplifies deployment and management.
Installing Hardal via GTM allows you to easily manage analytics implementation without changing your website code directly.
Prerequisites
Before you begin the installation, ensure you have:
- Access to your Google Tag Manager account
- A Hardal account with your signal ID and endpoint URL
- Admin privileges to publish GTM container changes
- Basic understanding of GTM triggers and variables
Hardal Tag Installation
Get your Hardal Script
- Log into your Hardal account
- Navigate to settings
- Copy your Hardal Script from “Setup” tab
Create a Hardal Tag
- Log in to your Google Tag Manager account
- Select your web GTM container
- In the left sidebar, go to Tags
- Click New to create a new tag
- Name your tag “Hardal”
- Click on the tag configuration area
- Select Custom HTML as the tag type
Add the Hardal Script
- Paste your Hardal Script you Tag’s HTML code.
If you have a custom domain set up for Hardal, use that domain as your hardalEndpoint instead of the default endpoint.
Set Up Trigger for Tag
- Click on the Triggering section
- Select the All Pages trigger to fire the tag on all pages
- Alternatively, create a custom trigger if you only want to track specific pages
Save the Tag
- Click Save to save your tag configuration
Important: The base Hardal installation ONLY tracks page views automatically. You must set up additional tags to track other events such as purchases, add to cart actions, etc.
Setting Up Event Tracking
Since the base Hardal tag only tracks page views, you need to create separate tags for each event you want to track:
Create Event-Specific Tags
For each event you want to track, create a new Custom HTML tag in GTM:
- Go to Tags and click New
- Name your tag (e.g., “Hardal - Purchase”, “Hardal - Add To Cart”, etc.)
- Select Custom HTML as the tag type
Add Event Tracking Code
Add the appropriate code snippet for the event you want to track. Here are examples for common e-commerce events:
Purchase Event:
Add to Cart Event:
View Item Event:
In Google Tag Manager, replace the placeholder variables (like dataLayerValue) with your actual GTM variables using the variable selection interface.
Set Up Triggers for Event Tags
- Click on the Triggering section for each event tag
- Create or select the appropriate trigger for the event
- Common triggers include:
- Custom Event triggers (e.g., “Custom Event - Purchase”)
- Click triggers (for tracking button clicks)
- Form submission triggers
- History change triggers (for single-page applications)
Save and Test Each Event Tag
- Save each event tag after configuration
- Test the tags individually using GTM Preview mode (see Verification section)
Variable Implementation
To properly track events, you’ll need to set up GTM variables that correspond to your specific data layer structure.
In Google Tag Manager, you select variables by clicking on the variable selection button (puzzle piece icon) when editing tags.
Common variables you’ll need to set up:
Data You Need | Variable Purpose | Description |
---|---|---|
Transaction ID | For purchase events | Unique ID for purchase transactions |
Value | For monetary values | Monetary value of the event |
Items | For product details | Array of product information |
Currency | For transaction details | Transaction currency |
Custom | For custom needs | Custom data |
To create these variables:
- Go to Variables in GTM
- Click New under User-Defined Variables
- Select Data Layer Variable as the type
- Enter the data layer path (e.g., “ecommerce.items”)
- Save the variable with an appropriate name
Publishing Your Configuration
Preview and Test
- Click Preview to test your tags before publishing
- Verify that all tags fire as expected (see Verification section)
Submit and Publish
- Once testing is complete, click Submit
- Add a version name and description
- Click Publish to make your changes live
Verification
After installation, verify that Hardal is working correctly:
Use GTM Preview Mode
- Click Preview in your GTM interface
- Enter your website URL and click Start
- Your website will open with the GTM debug panel
- Verify that the Hardal base tag fires on page load
- Perform actions that should trigger your event tags (purchases, add to cart, etc.)
- Confirm these tags fire at the appropriate times
Check Network Requests
- Open your browser’s developer tools (F12 or Right-click > Inspect)
- Go to the Network tab
- Refresh the page
- Look for requests to your Hardal endpoint domain
- Verify that events are being sent successfully
Check Hardal Dashboard
- Log in to your Hardal dashboard
- Navigate to the analytics section
- Verify that data is being collected and displayed correctly