Skip to main content
All CollectionsSecurity & Compliance
How to add a custom script that sets cookies
How to add a custom script that sets cookies

Learn how to add a custom script that sets cookies, which only runs if the visitor has accepted the relevant cookies

Evelina Lundmarck avatar
Written by Evelina Lundmarck
Updated over a year ago

Some custom scripts that you want to add to your career site will also set cookies or other tracking mechanisms in the visitor's browser. By following this guide you'll learn how to ensure that the script runs and cookies are set only when the visitor has accepted the relevant cookie category.

This guide contains of three steps;

  1. Decide which category the cookie falls under

  2. Add the custom script as custom JavaScript within the Global design under Content

  3. List the cookie in your Cookie Policy via Settings--> Cookies

1. Decide which category the cookie falls under

There are three categories of cookies that a visitor needs to provide their consent to: Analytics, Marketing, and Preferences:

Analytics: These cookies collect information that is used to help you understand how the site is being used.

Marketing: These cookies are used to make advertising messages more relevant to the visitor, like selecting advertisements that are based on their interests. In some cases, they also perform a function on the site, such as social media integrations.

Preferences: These cookies allow the site to remember information that changes the way the site behaves or looks, such as visitors preferred language or the region they are in. Loss of information stored in a preference cookie may make the experience less functional but should not prevent it from working.

Once you have decided which category your cookie(s) falls under, move on to the next step.

2. Add the custom script

The actual script is provided by the service you want to add, it probably looks something like;

<script>
(function() {
scriptThatWillSetACookie();
})();
</script>

You need to make a small change to make it recognizable as a script that sets cookies. Add data-cookie-type="your-category" to the <script> tag.

The available types are analytics, marketing and preferences.

So, if this script to fall under marketing, the script that you add will end up looking something like this;

<script data-cookie-type="marketing" type="text/plain">
(function() {
scriptThatWillSetACookie();
})();
</script>

3. Add the cookie in settings

In Teamtailor, go to Settings → Data & Privacy → Cookies and list the cookie under the relevant category; Analytics, Marketing or Preferences in the Cookie policy. You can see a more detailed explanation on how to list a cookie here.

All done! The script will not run, and the cookie will not be set, until the visitor has accepted the relevant cookie cartegory 👍

Did this answer your question?