Implement Event Tracking
There are two main ways to set up Event Tracking within FirstHive CDP. The first is with the built-in Tag Manager. The second is by adding snippets of JavaScript code directly to your website. Details for both methods are below.
How to Set Up Event Tracking With FirstHive CDP Tag Manager (Recommended)
If you have FirstHive CDP Tag Manager installed, this is the easiest way to implement event tracking. You can create a Tag for each type of event you want to track. Below is a step-by-step example for tracking email link clicks on your site:
- Set up and configure FirstHive CDP Tag Manager (create a container and install the container code).
- Click on Tag Manager in FirstHive CDP and go to the Tags page.
- Click the green Create New Tag button.
- Select the FirstHive Analytics tag type.
- Give your Tag a descriptive name, e.g., FirstHive Event – Email Link Click.
- Confirm your FirstHive configuration. If unsure, use the default settings.
- Select Event as the Tracking Type.
Next, add your event structure:
- Event Category: Contact
- Event Action: Email Link Click
- Event Name: {{ClickDestinationUrl}}
- Event Value: (optional)
Note: The Event Name is dynamically populated from a Tag Manager Variable that pulls data from the website.
Next, set up your Trigger:
- Click to create a new trigger.
- For this example, select **All Links Click **under the Click section.
- Name the trigger
All Email Links
. - To track only email links, configure the **Only trigger when **section:
- Field: Click Destination URL
- Condition: starts with
- Value:
mailto:
- Click **Create New Trigger **to finalize.
- Attach the Trigger to your Tag and click Create New Tag.
- Publish your container via the success message or menu option.
Once live, test by clicking an email link on your site and reviewing the Visits Log in FirstHive CDP. You should see your event recorded in real time
Note: Tag Manager can trigger tags based on IDs or classes. If your element lacks unique identifiers, consider adding a unique ID, class, or other HTML attribute—developer assistance may be needed.
How to Set Up FirstHive CDP Event Tracking With JavaScript
For more technical users, you can implement event tracking by adding a JavaScript snippet directly into your website code.
Links are the most common elements for tracking events. A standard HTML link:
<a href=“mailto:name@example.com” title=“Email Us”>Email Us</a>
You can extend it with an onClick function:
<a href=“mailto:name@example.com” title=“Email Us” onclick=“_fh.push([‘trackEvent’, ‘Contact’, ‘Email Link Click’, ‘name@example.com’]);“>Email Us</a>
This example tracks:
- Event Category: Contact
- Event Action: Email Link Click
- Event Name: name@example.com
The function works as follows **_fh.push([ ]) **sends data to FirstHive CDP, and trackEvent defines the event. The next attributes are interpreted as Category, Action, Name, Value (Value is optional).
For example, tracking a wishlist addition with a value:
_fh.push([‘trackEvent’, ‘Ecommerce’, ‘Add to Wishlist’, ‘Smartphone’, 1000]);
- Event Category: Ecommerce
- Event Action: Add to Wishlist
- Event Name: Smartphone
- Event Value: 1000