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 Optimize UI to help users assess priority of issues found on their domain.
As noted above, it is possible to do simple page view counting in Optimize without the Statistics module enabled. To disable the basic page views feature, track_pageviews_on_load
must be set to false
.
When Statistics is enabled, the Optimize Script is by default setting a cookie called monsido
. It contains a random string that Optimize is using to identify a visitor's returning visits. The cookie automatically expires 30 days after the visitor's latest visit. It is not shared across domains or with Optimize customers in general.
Visit our Help Center for more information about the tracking cookie.
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
.
If the script is used for an SPA, 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)
. A URL is not required. If the URL is empty, it will call the current URL.
Optimize 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 Optimize UI, you can see how many times a tracked element has been clicked by visitors.
For Event tracking to work, the Optimize script does not need to be modified. However, a separate script must be added to the specific element for which you want to track interactions.
Find more information and examples of how to set up Event tracking in our Help Center.
It is possible to activate cookieless tracking in Optimize. With cookieless tracking enabled, Optimize will track visitors without setting a cookie on their device.
To enable this feature, activate the setting window._monsido.statistics.cookieLessTracking
.
If you are using a consent management solution like a cookie banner to collect tracking consent from visitors, you can set it to activate cookieless tracking when consent is provided and and remove it when consent is revoked. Set your consent management product to call the function window.monsido_functions.setCookieConsent()
when an end user is giving consent. 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 number of results. Be aware that when calling this, the Optimize script should be done loading first. It is possible to listen to the event for when the Optiimize 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 search 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);
}
});
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Mon Oct 21 2024 02:41:37 GMT+0000 (Coordinated Universal Time)