Vanilla Mautic’s tools provide a solution to track what pages do visitors – even anonymously – visit on our site.
If you also want to track users on a site where they can log in with a password, it’s a good idea to use the tracking code with the email added as a parameter after the user logged in. Setting the email identifies the contact toward Mautic that allows us to contact the user via Mautic messages. Also at the same time it istructs Mautic to log the following events (page visits) to the current contact.
But if another user logs in, Mautic does not change the IDs of the tracked contact, but treats as if the two different users were the same, thus merging them.
The cookie of the currently tracked contact is always stored to the Mautic domain. Deleting a cookie on the host page therefore does not change which user Mautic tracks.
Tracking takes place on the client side, so the deletion of the cookie must also take place on the client side. The feature is integrated into the Mautic JS API.
If a user logs out, we can stop tracking by calling the appropriate JS function.
When a user logs in, you can invoke the JS function to delete the tracking cookies to prevent two different users from being merged when identifying the logged-in user to Mautic with an email address.