You can easily create a simple cookie consent using Mailocator. This consent is fully functional for sites that use a limited number of third party scripts - such as Google Analytics, Facebook pixel and a few others.
If your site contains a large number of external components that require detailed management, we recommend using specialized consent management software.
Create a cookie consent campaign
Create an infobox campaign, add the necessary text for consenting to cookies and add two buttons - one for accepting and one for rejecting consent
add the following Mailocator action to the accept button:
mailocator.do('setCookie:consent,1 | jsfn:afterConsent() | close ');
Importance of the action
- action creates a cookie named
consent
and inserts the value1
- the
jsfn
action executes a javascript function that activates all components that depend on the consent - the
close
action closes the window, which is no longer displayed for the duration of the session
add action on the button to refuse consent:
mailocator.do('close');
- the consent window will simply close without creating a cookie indicating consent
Functions for activating consent-dependent components
To enable consent-based execution of all components that require consent, add a simple function to your site (or GTM, or as an external Mailocator script) that conditions the presence of a consent-based cookie:
// does cookie "consent" exists?
isConsentCookie=()=>{
for( let cookie of document.cookie.split('; ') ){
const [cookieName, cookieValue] = cookie.split('=');
if (cookieName === 'consent')
return true;
}
return null;
};
// components based on content
var
afterConsent=()=>{
/* cookie based scripts follows... */
};
if (isConsentCookie)
afterConsent();
- the first function detects if a cookie is present
consent
- the second feature includes all scripts like Facebook pixel, analytics and tracking systems and more...
- the last routine triggers the function at the moment where the cookie exists with each opening of the next page
Withdrawal of consent
To withdraw consent, place a link in your site (ideally in the footer) that opens the consent window again using a Mailocator action, for example:
<a href="#" onclick="mailocator.do('triggerID:XXXX')">Manage consent</a>
- after XXXX insert the campaign ID to accept cookies
Managing consent for Google Tag Manager
If you are using GTM and have set consent levels, you can add the necessary events to the dataLayer instead of the consent
cookie mechanism described above.
to write the value to the dataLayer use the dlPush
action as follows:
mailocator.do('dlPush:analytics_storage,1 | close ');
For more information, visit Google:
https://support.google.com/tagmanager/answer/10718549?hl=en