Tracking Known WordPress Users in Mautic with the Official Mautic Plugin

Mautic Logo

A new option was recently added to the official Mautic Wordpress plugin (Version 2.1.0), but it won't do anything out of the box.

Here's how to set it up to track extra information from your logged-in users.

You can find the new option in the settings page:

Mautic track known Wordpress users

After enabling the user tracking, new information will be added to the javascript snippet for email, first name and last name as well as some other specific Wordpress user data such as the username, display name and registration date.

You can find the relevant code on GitHub here.

To get Mautic to use this information, you first need to make the email, firstname and lastname fields publicly updateable otherwise Mautic will ignore the data.

To change the field information, click on the gear wheel in the top right of the admin area to open the administration menu and select 'custom fields':

Edit Mautic custom fields

Open up the 3 fields in turn and switch on the publicly updatable option in the right menu:

Mautic make field publicly updatable

Logged in users should now get their email address and first and last names updated after logging in.

To store the extra Wordpress related information, we first need to create the fields to store the data.

These steps are optional, if you don't want to store this information then you can leave out the following steps and Mautic will just ignore the extra information.

First, let's create a new field to store the Wordpress username. In the field listing view, click on the 'new' button in the top right of the screen and fill in the fields and set the options as in the following image:

Mautic new custom field

The most important options are the alias field, which needs to match the field value sent from the Wordpress plugin and the publicly updatable option which allows the field to be updated with the tracking script (As we just changed for the code email and name fields).

You can change the other switches as you wish. In the image, I've set most things off as I'm just keeping the values for informational purposes.

Do the same for the other fields with the aliases: wp_alias (Display name), wp_registration_date (Set the 'Data Type' option to 'Date' rather than 'Text' for this one).

You should now start to gather information about users when they log into your site, either updating existing information or adding it to turn an anonymous contact into a known one.

Caveats

If you are tracking multiple Wordpress sites and the contact is a member of more than one site then logging into any site will overwrite the field values. If you need to track multiple sites then it's better to create your own unique fields and use a filter to insert the information to send.

Custom Attributes

If you want to send other user information that isn't added by default then check this post: How to Send Custom Attributes with the Official Mautic WordPress Plugin