# Enable User ID Tracking

To enable User ID functionality, you need to start sending User IDs to your marketing engine dashboard.&#x20;

1. To start, 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.&#x20;
   1. 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.
2. The next step is to send this unique identifier through to Satisfi Labs 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 <a href="#user_id_for_wordpress" id="user_id_for_wordpress"></a>

{% hint style="info" %}
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.
{% endhint %}

### **Satisfi Labs for WordPress: How to Enable User ID Tracking**

1. Log in to your WordPress dashboard with an admin account.
2. Hover over **Satisfi Labs 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-Satisfi Labs: 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 Tag Manager <a href="#user_id_for_factoreal_tab_manager" id="user_id_for_factoreal_tab_manager"></a>

The method for configuring User ID tracking with 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 Tag Manager for your site.**
2. **Create a variable called&#x20;*****UserID*****&#x20;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](https://matomo.org/docs/tag-manager/#user-defined-variables) 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](https://developer.matomo.org/guides/tagmanager/datalayer#setting-a-variable) with a little custom code.
3. **Create or update your&#x20;*****Marketing Engine Configuration*****&#x20;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 tracking configuration.
4. **Preview and publish your updated container.**\
   While previewing, you can visit your website and a 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 Tag Manager. Once confirmed, publish your container to begin tracking User IDs.

## How to Send User ID with the JavaScript Client <a href="#user_id_for_js_client" id="user_id_for_js_client"></a>

If you have a completely custom website, you can add a JavaScript snippet of code to your website which sends the **User ID** to the marketing engine 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 the marketing engine. ‘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 tracking code, above the action that you are tracking.

For example, the code above within the standard pageview tracking code would look 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 -->
> ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.satisfilabs.com/resource-center/marketing-engine/settings-and-integrations/integrations/website-tracking/enable-user-id-tracking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
