Skip to content

Implementing Tracking or Cookie Consent with the JavaScript Tracking Client

In the context of GDPR/LGPD privacy regulations, when you process personal data, in some cases, You will need to request consent from your users. To identify whether you need to request any consent, you need determine whether your legal basis for processing personal data is "Consent" or "Legitimate Interest" or whether you can avoid the collection of personal data completely. We recommend learning more about the legal basis under GDPR and the LGPD in Brazil.

The MVMCloud Analytics differentiates between tracking and cookie consent:

  1. Tracking Consent: No cookies will be used and no tracking requests will be sent unless consent has been given. Once consent is given, tracking requests will be sent and cookies will be used.
  2. Cookie Consent: Tracking requests will always be sent. However, cookies will only be used if consent to the storage and use of cookies is given by the user. Learn how cookies affect reporting accuracy.

Using MVMCloud Analytics features

If you're not using an external consent manager, follow the steps below to prompt users for tracking and consent. cookies before your data is processed in MVMCloud Analytics.

  • Ask for consent To request consent, insert the following line at the top of your MVMCloud Analytics tracking code on all of your pages:
// require user tracking consent before processing data
_paq.push(['requireConsent']);

// OR require user cookie consent before storing and using any cookies
_paq.push(['requireCookieConsent']);

_paq.push(['trackPageView']);
[...]

After the requireConsent function is executed, no tracking requests will be sent to MVMCloud Analytics and no cookies will be set.

After the requireCookieConsent function is executed, tracking requests will still be sent, but no cookies will be set.

  • Request consent through your privacy notice You can ask for user consent, for example, by displaying a clear privacy notice on your pages. Note that MVMCloud Analytics does not yet offer the feature to display a privacy notice, but we may implement this feature in the future to allow you to easily display the notice and obtain user consent.

  • User gives consent After a user gives consent, you can either A) let MVMCloud Analytics remember the consent, or B) use your own consent tool to remember the consent. We present the two solutions below:

    • If you want to let MVMCloud Analytics remember consent After a user has given consent, you can allow MVMCloud Analytics to remember that the user has given consent by simply calling the following method after the user has given consent:
      // remember that tracking consent was
      // data for all page views and subsequent visits
      _paq.push(['rememberConsentGiven']);
      // OR remember that cookie consent was
      // data for all page views and subsequent visits
      _paq.push(['rememberCookieConsentGiven']);
      

    MVMCloud Analytics will remember on subsequent requests that the user gave their consent by setting a cookie called "consent". As long as this cookie exists, MVMCloud Analytics will know that consent has been given and will automatically process the data. This means that you only need to run _paq.push(['rememberConsentGiven']) or _paq.push(['rememberCookieConsentGiven']) just once.

    Grades:

    * By default, the cookie and consent will be remembered forever. You can set an optional expiration period for the
      user consent by running: `_paq.push(['rememberConsentGiven', optionallyExpireConsentInHours])` or `_paq.push(['rememberCookieConsentGiven', optionallyExpireConsentInHours])`.
    * When tracking multiple subdomains on the same site in MVMCloud Analytics, you want to ensure that when asking for consent, the user gives consent for all subdomains where you are collecting data. If the user only gives consent for a certain domain or subdomain(s), you may need to narrow or widen the domain scope and path of the consent cookie using '`setCookieDomain`' and '`setCookiePath`'.
    * For consent to work, the user must not disable first-party cookies.
    
    • If you use your own tool to remember consent In some cases, you record the information the user has given consent to be tracked directly into your own system or CMS (for example, when you use your own cookie to remember user consent). Once you have the user's consent to process their data, you need to call the setConsentGiven or setCookieConsentGiven method
        // require user tracking consent
        // before processing data
        _paq.push(['requireConsent']);
      
        // OR require user cookie consent
        // before storing any cookies
        _paq.push(['requireCookieConsent']);
      
        _paq.push(['trackPageview']);
        [...]
      
        // the user has given consent to process their data
        _paq.push(['setConsentGiven']);
      
        // OR the user has given consent to store and use cookies
        _paq.push(['setCookieConsentGiven']);
      

    This lets the JavaScript tracker know that the user has given consent and ensures that tracking is working as expected. This function needs to be called at any time after _paq.push(['requireConsent']) or _paq.push(['requireCookieConsent']).

    Grades:

    * When you run `_paq.push(['setConsentGiven'])` or `_paq.push(['setCookieConsentGiven'])`, MVMCloud Analytics will not remember in subsequent requests that this user gave consent: it is It is important that you call `setConsentGiven` on every page.
    * When the user gives consent, you can also avoid running `_paq.push(['requireConsent'])` in the first place.
    
  • User withdraws consent

To withdraw consent, the user needs to perform a specific action, for example: clicking a "I no longer want to be tracked" button.

* **If you want to let MVMCloud Analytics remember consent**
  When the user expresses that they no longer give consent, you will need to call the following method once:

            // revoke consent for tracking
            _paq.push(['forgetConsentGiven']);

            // OR revoke cookie consent
            _paq.push(['forgetCookieConsentGiven']);

  This ensures that the cookie providing consent is deleted.

* **If you use your own consent tool to remember consent**
  When the user expresses that they no longer give consent, you should no longer call the following method:

            // don't call this after the user removes their consent
            _paq.push(['setConsentGiven']);

            // OR this method if you are using cookie consent
            _paq.push(['setCookieConsentGiven']);

Creating a custom opt-out form

Want to create a custom opt-out form instead of a consent screen? Check out the guide for creating a custom cancellation form.