Track User IDs with Ghost Metrics
Ghost Metrics offers a User ID tracking feature to enhance analytics for websites with user login systems, while ensuring compliance with HIPAA regulations. This feature allows you to associate a unique identifier, such as a user ID or email address, with a user’s analytics data, improving visitor tracking across sessions and devices.
By default, Ghost Metrics fully anonymizes all data and does not collect User IDs to prioritize privacy. Enabling User ID tracking allows the collection of customer-defined identifiers, including email addresses, in a HIPAA-compliant manner. To enable this feature, contact Ghost Metrics Support at support@ghostmetrics.io.
What is User ID Tracking?
User ID tracking links a unique, customer-defined identifier to a user’s analytics data. This enables Ghost Metrics to connect a user’s actions across multiple visits and devices using a HIPAA-compliant identifier, such as a user ID, hashed value, or email address.
Benefits of User ID Tracking
- Improved Visitor Accuracy: Track unique visitors across devices and sessions, reducing duplicate counts.
- Enhanced Reporting: Access detailed reports under Visitors > User IDs in your Ghost Metrics dashboard, showing user interactions, visit frequency, and goal conversions.
- HIPAA Compliance: User IDs, including email addresses, are collected securely under a BAA, ensuring compliance with healthcare privacy standards.
Prerequisites for User ID Tracking
To use User ID tracking, your website must have a login system that assigns a unique identifier to each user, such as a user ID, hashed value, or email address. Ghost Metrics’ BAA ensures that even identifiers like email addresses can be collected in a HIPAA-compliant manner.
How to Set Up User ID Tracking
Configure User ID Tracking with Ghost Metrics Tag Manager
The method for configuring User ID tracking with Ghost Metrics Tag Manager will vary depending on how your website has been built. As there is no standardized way of including User IDs within your website code, you will likely need to set this up yourself or get developer assistance.
- Install and configure Ghost Metrics Tag Manager for your site.
- Create a variable called UserID that captures each visitor’s unique user identifier.
If you display usernames on the front-end of your site, you may want to create a variable from an HTML DOM selector whilst a user is logged in. Or, for a more flexible method, you can configure your website to expose a user’s unique identifier, such as an email address, to the data layer with a little custom code. The simplest method for making sure that a user’s email address can be read consistently and tracked to Ghost Metrics may be to first build your website so that it has a cookie which contains the value of your visitor’s email address in a first-party cookie. Then, in Ghost Metrics, a Tag Manager variable can be configured to read directly from a First-Party cookie. Or consider this alternative: store the email address as local storage in the browser instead. This would then need to be retrieved using a Custom JavaScript Variable that retrieves the value from local storage to be used in the Tag Manager as a variable. - Create or update your Ghost Metrics Configuration variable to collect the UserID.
Assuming you named your User ID variable in the last step UserID, you would scroll down to the User ID text field and input{{UserID}}
to pull the values captured by that variable into your Ghost Metrics tracking configuration. - Preview and publish your updated Ghost Metrics container.
While previewing, you can visit your website, and a Ghost Metrics Tag Manager debug screen will show at the bottom half of your screen. You can click the Variables tab within this to ensure the UserID variable is being picked up correctly by Ghost Metrics Tag Manager. Once confirmed, publish your container to begin tracking User IDs.
How to Send User ID with the JavaScript Client
If you have a completely custom website, you can add a JavaScript snippet of code to your website, which sends the User ID to Ghost Metrics via the JavaScript Tracking API. To do this, you would add the unique identifier for a user to the following snippet of code:
_paq.push(['setUserId', 'USER_ID_HERE']);
The example above, _paq.push([ ]);
sends the data to Ghost Metrics. 'setUserId'
defines what data is being sent,
and you should configure the second argument 'USER_ID_HERE'
, to dynamically contain the unique User ID of the
visitor currently viewing the page. This code should be placed within your Ghost Metrics tracking code, above the action
that you are tracking.
For example, the code above within the standard Ghost Metrics pageview tracking code would look a little something like this:
<!-- Ghost Metrics -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['setUserId', 'USER_ID_HERE']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://{$GHOST_URL}/";
_paq.push(['setTrackerUrl', u+'js/tracker.php']);
_paq.push(['setSiteId', {$IDSITE}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'js/tracker.php'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Ghost Metrics Code -->
For more details on this method, consult the developer documentation on User IDs.
Privacy and HIPAA Compliance
Ghost Metrics ensures User ID tracking aligns with HIPAA by:
- Default Anonymization: By default, all data is fully anonymized, and no User IDs are collected.
- Secure User ID Collection: When User ID tracking is enabled, customer-defined identifiers (including email addresses) are collected securely under a Business Associate Agreement (BAA), ensuring HIPAA compliance.
- Consent Management: If your website requires user consent for tracking (e.g., under GDPR or CCPA), Ghost Metrics can integrate with your consent management platform. Contact support@ghostmetrics.io to configure this.
- Data Security: Analytics data is stored securely in Ghost Metrics’ HIPAA-compliant infrastructure, accessible only to authorized users.
Troubleshooting
If User ID data isn’t appearing in your reports:
- Verify that your website’s login system exposes the chosen identifier (e.g., user ID or email address).
- Ensure the identifier is consistently available (e.g., in the data layer or a cookie) when users are logged in.
- Contact support@ghostmetrics.io with details of the issue, including your site ID and any error messages.
Next Steps
Ready to enable User ID tracking? Email support@ghostmetrics.io to start the process.