Complianz Privacy Suite

Changing JavaScript for Consent Purposes

Aert Hulsebos

Aert Hulsebos

Categories

Popular articles

Creating the Legal Hub

Have you seen our new Legal Hub? If not, have a look before reading this instruction article. We created the legal hub to centralize our

Read More

Placeholders for iFrames

From 4.6.11 onwards, you can also use consent shortcode wrappers. An instruction can be found here. You’re able to block iFrames with Complianz with the

Read More
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

You might need to add JavaScript to your website, only it should only be trigger when a certain type of consent has been given. There are 3 options:

  1. Add the JavaScript snippet to our Script Center. Either in the first snippet box or, if you have an asynchronous snippet, you can use the second snippet box.
  2. Use Google Tag Manager for this purpose. You can use the Complianz event triggers for this purpose.
  3. Add JavaScript however you like, but change the actual snippet to adjust for Complianz.

We will discuss option number 3 in this article.

Before we start. We removed the <> from all script tags so we can show the code. Please remember when trying to copy/paste our example. In the below example code you will see ! instead of where the <> were.

!script!
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '{your-pixel-id-goes-here}');
  fbq('track', 'PageView');
!/script!

Changing the snippet so Complianz won’t block before consent.

If you want to tell Complianz it should not block your javascript add the following property:

class="cmplz-native"

For example:

!script type="text/javascript" class="cmplz-native"!

Changing the snippet so Complianz will activate on Statistics.

If you want to tell Complianz it should block your javascript until consent for statistics is set use:

class="cmplz-stats"

and

type="text/plain"

For example:

!script type="text/plain" class="cmplz-stats"!

Changing the snippet so Complianz will activate on Marketing.

If you want to tell Complianz it should block your javascript until consent for marketing is set use:

class="cmplz-script"

and

type="text/plain"

For example:

!script type="text/plain" class="cmplz-script"!

For example, a Facebook pixel as shown above:

!script type="text/plain" class="cmplz-script" !
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '{your-pixel-id-goes-here}');
  fbq('track', 'PageView');
!/script!

Recent articles

Subscribe