Enable User ID Tracking

To enable User ID functionality, you need to start sending User IDs to Factoreal. First, you will need to identify what data your site holds for each user that can be used as a User ID. Every website system that allows people to log in should have at least one unique identifier that it uses to differentiate between users. This may be a unique number, a username, or simply a user’s email address.

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

The next step is to send this unique identifier through to Factoreal Analytics. The exact method for doing this will vary depending on how your site was built. You can find step-by-step instructions for the various methods below.

How to Configure User ID Tracking for WordPress

Note: WordPress users can typically change their email address, but not their username. When selecting a unique identifier in the guides below, select Username if you want the most reliable long-term identifier. However, if you also want to capture a User ID from form submissions of logged out users too, you should use Email Address instead.

Factoreal for WordPress: How to Enable User ID Tracking

  1. Log in to your WordPress dashboard with an admin account.
  2. Hover over Factoreal Analytics in the menu and click Settings within the sub-menu.
  3. Scroll down to the User ID dropdown and select Email Address or Username.
  4. Click the blue Save Changes button below, and User ID tracking will be enabled.

WP-Factoreal: How to Enable User ID Tracking

  1. Log in to your WordPress dashboard with an admin account.
  2. Hover over Settings in the menu and click on WP-Matomo depending on which version you have installed.
  3. Click on the Enable Tracking
  4. Enable a non-manual tracking method in the Add tracking code
  5. Scroll down to the User ID Tracking setting and select Email Address or Username in the dropdown.
  6. Click the blue Save Changes button, and User IDs will begin tracking immediately.

How to Configure User ID Tracking with Factoreal Tag Manager

The method for configuring User ID tracking with Factoreal 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.

  1. Install and configure Factoreal Tag Manager for your site.
    Learn more about getting started with Factoreal Tag Manager.
  2. 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 a 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.
  3. Create or update your Factoreal 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 Factoreal tracking configuration.
  4. Preview and publish your updated Factoreal container.
    While previewing, you can visit your website and a Factoreal 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 Factoreal 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 Factoreal 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 Factoreal. ‘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 Factoreal tracking code, above the action that you are tracking.

For example, the code above within the standard Factoreal pageview tracking code would look a little something like this:

<!-- Factoreal -->
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];
  _paq.push(['setUserId', 'USER_ID_HERE']);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//{$FACTOREAL_URL}/";
    _paq.push(['setTrackerUrl', u+'tracker.php']);
    _paq.push(['setSiteId', {$IDSITE}]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'Factoreal.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Factoreal Code -->

For more details on this method, consult the developer documentation on User IDs.