Skip to main content

Tracking

By default, the simplest version of the Monsido script is the following:

window._monsido = window._monsido || {
token: "insert-your-monsido-token-here";
}

This will track page views without setting a cookie. The page view data is populated inside the Monsido UI to help users assess priority of issues found on their domain.

Page views without statistics

As noted above, it is possible to do simple page view counting in Monsido without the Statistics module enabled. To disable the basic page views feature, track_pageviews_on_load needs to be set to false.

Statistics

When Statistics is enabled, the Monsido Script is per default setting a cookie called monsido. It contains a random string that Monsido is using to identify a visitor's returning visits. The cookie auto expires after 30 days after the vistiors's latest visit. It is not shared across domains or with Monsido customers in general.

Visit our Help Center for more information about the tracking cookie

Document tracking

If document tracking is enabled, the script automatically tracks clicks on links with files ending on the extension setup in window._monsido.statistics.documentTracking.documentExt.

It is also possible to track using CSS classes with window._monsido.statistics.documentTracking.documentCls.

Documents can be ignored from the automatic tracking using window._monsido.statistics.documentTracking.documentIgnoreCls.

SPA tracking

If the script is used for an SPA (Single-Page Application) it is important to disable automatic tracking. This can be done by setting the option track_on_load to false: window._monsido.statistics.track_on_load.

Now, tracking can be called by using the function window.monsido_tracking.trackUrl(url). URL is not required. If URL is empty, it will call the current URL.

Event tracking

Monsido Events is an event tracking feature in the Statistics module that allows you to track visitor interactions on your website. You can add event tracking to any clickable element on your web pages, for example buttons, links, dropdowns and widgets. In the Monsido UI, you can see how many times a tracked element has been clicked by visitors.

For Event tracking to work, the Monsido script does not need to be modified. However, a separate script must be added to the specific element that you wish to track interactions on.

Find more information and examples of how to set up Event tracking in our Help Center

Cookieless Tracking

It is possible to activate cookieless tracking in Monsido. With cookieless tracking enabled, Monsido will track vistiors without setting a cookie on their device.

To eanble this feature, activate the setting window._monsido.statistics.cookieLessTracking.

If you're using a consent management solution like a cookie banner to collect tracking consent from vistiors, you can set it to activate cookieless tracking when consent is provided and and remove it when consent is revoked. Set your constent management product to call the function window.monsido_functions.setCookieConsent() when an end user is giving consent. Now a cookie will be created. If the end user withdraws the consent, call the function window.monsido_functions.removeCookieConsent(). The cookie is deleted.

Visit our Help Center to learn more about how Cookieless Tracking works

To track searches that visitors are performing on your website, use the trackSearch feature. The function itself looks like this: window.monsido_functions.trackSearch(searchString, searchCount) The script should be added on the search results page of the website. Param one (required) is the search string, param two (optional) is the amount of results. Be aware that when calling this, the Monsido script should be done loading first. It is possible to listen to the event for when the Monsido script is done loading:

window.addEventListener('mon-script-loaded', () => {
console.log('Monsido script loaded');
});

An implementation with the search string in the URL could look something like this on the serach results page:

window.addEventListener('mon-script-loaded', () => {
const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
if (params.searchString) {
window.monsido_functions.trackSearch(params.searchString);
}
});