Skip to main content

Add custom scripts that set cookies

Implement 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 today

Certain custom scripts on your career site may set cookies or tracking mechanisms in a visitor’s browser. This guide explains how to ensure those scripts run only after the visitor has accepted the appropriate cookie category.

This guide consists of three steps:

  1. Decide which category the cookie falls under

  2. Add the custom script as JavaScript within the Design settings in the Career site editor

  3. List the cookie in your Cookie Policy via Settings → Data & Privacy → 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) fall 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 falls 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 All cookies. Add the cookie under the relevant category: Analytics, Marketing, or Preferences. You can see a more detailed explanation on how to list a cookie here.

After this final step is done, the script will not run, and the cookie will not be set, until the visitor has accepted the relevant cookie category.

Did this answer your question?