Skip to content

Set up User ID Tracking

To enable User ID functionality in FirstHive CDP, you need to start sending User IDs to the platform. First, identify what data your site holds for each user that can be used as a unique identifier. Every system that allows users to log in will have at least one unique value—such as a user ID number, username, or email address.

It is recommended to set a user’s email address as the User ID when possible. This ensures you can also track the same user when they complete a contact or subscription form, even if they are logged out.

The next step is to send this unique identifier to FirstHive CDP. The exact method depends on your website setup. Below are the different methods available.

Configuring User ID Tracking for WordPress

If you are using WordPress, there are two main ways to integrate with FirstHive CDP:

  1. FirstHive CDP for WordPress Plugin – where the CDP is embedded directly in your WordPress environment.
  2. FirstHive Connector Plugins (WP-FirstHive, WP-Piwik) – for FirstHive CDP Cloud or On-Premise deployments.

Note: WordPress users can typically change their email address, but not their username. If you want the most reliable long-term identifier, select Username. If you also want to track form submissions for logged-out users, use Email Address instead.

FirstHive CDP for WordPress: Enable User ID Tracking

  1. Log in to your WordPress dashboard with admin access.
  2. Hover over FirstHive CDP Analytics in the menu → click Settings.
  3. Scroll to the User ID dropdown → select Email Address or Username.
  4. Click Save Changes. User ID tracking will now be enabled.

FirstHive Connector Plugin (WP-FirstHive, WP-Piwik): Enable User ID Tracking

  1. Log in to your WordPress dashboard.
  2. Navigate to Settings → Connect FirstHive CDP.
  3. Open the Enable Tracking tab.
  4. Enable a non-manual tracking method under Add tracking code.
  5. Scroll to User ID Tracking → select Email Address or Username.
  6. Click Save Changes. User IDs will begin tracking immediately.

Configuring User ID Tracking with FirstHive Tag Manager

If your site uses FirstHive Tag Manager, setup will vary based on your build. Since there’s no universal way of embedding User IDs into your code, you may need developer assistance.

Steps:

  1. Install and configure FirstHive Tag Manager on your site.
  2. Create a variable (e.g., UserID) that captures the visitor’s unique identifier.
  3. If usernames are visible on the front-end, you can use a DOM selector.
  4. Or configure your site to expose an identifier (e.g., email) in the data layer with custom code.
  5. A practical option: store the email in a first-party cookie or local storage, then create a Custom JavaScript Variable in Tag Manager to retrieve it.
  6. Update your FirstHive Configuration variable to collect the UserID.
  7. In the User ID field, enter {{UserID}}.
  8. Preview and test in Tag Manager’s debug mode to ensure the UserID variable is detected.
  9. Publish the container to begin tracking User IDs.

Sending User ID via JavaScript Tracking

For custom-built websites, you can use the FirstHive CDP JavaScript Tracking API to send User IDs.

Example snippet:

<script type=“text/javascript”> var fhq = window.fhq = window.fhq || []; fhq.push([‘setUserId’, ‘USER_ID_HERE’]); fhq.push([‘trackPageView’]); fhq.push([‘enableLinkTracking’]); (function() { var u=”//{$FIRSTHIVE_URL}/”; fhq.push([‘setTrackerUrl’, u+‘firsthive.php’]); fhq.push([‘setSiteId’, {$SITEID}]); var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0]; g.type=‘text/javascript’; g.async=true; g.src=u+‘firsthive.js’; s.parentNode.insertBefore(g,s); })(); </script>

  • setUserId defines the data being sent.
  • Replace USER_ID_HERE with your website’s dynamic User ID value.
  • Insert this code above the tracking action (e.g., before trackPageView).

Sending User ID with FirstHive SDKs

If you are using one of the FirstHive SDKs (e.g., iOS, Android, or other apps), simply call:

setUserId(USER_ID);

Or, you can pass the User ID via the FirstHive HTTP Tracking API.