How can I run third-party scripts only when a visitor agrees?
Sometimes, to be compliant with privacy laws, you need to ask for consent before running a third-party script on your website. By third-party script, we mean a code, pixel, or tag that communicates and shares your visitor’s data with another service. In such cases, we recommend using Consent Manager, which allows you to display a consent pop-up and adding the appropriate types to tags, which will ensure that the tags only fire for visitors who agree.
In this article, we’ll explain how to set it up.
First, let’s look at an example of a consent form.
Here a visitor can decide for which purposes his data can be processed. The purposes correspond to the tag types that you run on your website.
So when you have tags responsible for collecting analytics data, you set up the following tag type:
Analytics. And when you have tags responsible for remarketing, you apply the following tag type:
Remarketing. And so on. You can also create your own tag type or use a type:
Does not require consent. In the latter case, the tag will be fired to all visitors, no matter if they agree or not.
Now, coming back to running third-party scripts for visitors, here are the steps you should consider:
- Make a list of all third-party scripts that you use on your website. These may be scripts responsible for remarketing, customer contact or other advertising or supportive tools that you use.
- As a part of your audit, you can use our cookie scanner to see which cookies — first-party and third-party — you use on your website.
- We recommend that you add all third-party scripts via Tag Manager because you’ll be able to use the mechanism that fires tags to visitors who agree to a particular script purpose.
- Assign appropriate types to tags that run third-party scripts.
- Adjust messages in the consent form in Consent Manager.
- We also recommend that you create an internal process for adding all scripts, including third-party scripts, via Tag Manager. Each added script should have an appropriate tag type. This will help you keep all scripts organized and assigned to relevant consents.
Tip: You can access this setting by going to Menu > Tag Manager > select a tag > Advanced tag settings.
Tip: You can access this setting by going to Menu > Consent Manager > Consent templates > Consent form.