/ /

Classification Rules

Updated 19 days ago

Manage scripts and cookies with Osano's CMP auto-identification feature. Ensure compliance by classifying each tracker based on its functionality. Follow our guide to add Script or Cookie Classification Rules from scratch in the Consent Manager, enabling efficient grouping and classification.

Identifying Trackers (Scripts, Cookies, Iframes)

After inserting the Osano.js into the <head> of your website, the CMP will begin identifying the full URL of the scripts and cookies attempting to load on your site.

For the sake of compliance, each script and cookie should be classified as one of the following: Essential, Marketing, Analytics, Personalization, Blocklisted. (See Classification Categories for more info on these classification types.) Once classified, your users will be able to opt into and out of non-essential scripts and cookies based on their category.

Generally, any script or cookie that is required for your site to function (including navigation, scrolling, animations, content loading) should be classified as "Essential." Essential scripts will always be loaded, regardless of whether the user has consented or not. You should aim to never have any uncategorized scripts.

Classification Rules

In many cases, you will see multiple scripts and/or cookies loading from the same domain that can all be classified under the same category. This is more common for scripts.

Osano.com, for example, uses Facebook advertising and embeds Facebook JavaScript. Osano categorized all of the Facebook scripts as Marketing since that is their primary use. These scripts will only be loaded for users who have consented to "Marketing" cookies and scripts. We also load jQuery on the Osano.com website and a few other libraries from Cloudflare CDN, all of which are essential. Rather than categorizing each script individually, we simply tagged cloudflare.com as being Essential.

The best way to categorize these scripts is by creating a classification rule that applies to the specific domain identified.

Classification rules are a means of grouping similar scripts or cookies together based on a shared URL string. The Osano cookie consent manager accepts Postgres POSIX-style Regular Expressions to make classification easier to manage in the long run; however, you can also follow the examples below.

Types of Rules

Exact Match:

An exact match is a 1:1 match where the rule and the script or cookie are exactly the same:

  • Ex. Discovery: https://www.facebook.com/cdn/marketing/pixel

  • Exact Rule:https://www.facebook.com/cdn/marketing/pixel= 'MARKETING'

Path Match (Scripts and iFrames Only)

A path match involves creating a rule where the majority of the URL path is included. This would allow you to capture all content from a particular vendor up to a specific folder.

  • Ex. Discovery: https://www.facebook.com/cdn/marketing/pixel

  • Path Rule: https://www.facebook.com/cdn/ = 'MARKETING'

Note: It's important to end a path match with a trailing / to ensure appropriate matching.

Regular Expression (Regex):

Osano supports Postgres POSIX-style Regular Expressions. A regular expression allows you to utilize special characters (all with specific meanings) to all match patterns when creating rules.

  • Ex. Discovery: https://www.facebook.com/cdn/marketing/pixel

  • Regex Rule: facebook\.com= 'MARKETING'

Working Around the 3-Character Minimum

Osano requires a minimum of three characters when creating a script or cookie rule. If you need to match a shorter value, such as a two-character cookie name like MS, you can use anchors to satisfy the character minimum without changing what the rule matches:

  • ^ (caret) - placed at the beginning, tells Osano to match only values that start exactly here

  • $ (dollar sign) - placed at the end, tells Osano to match only values that end exactly here

    • Ex. Cookie name: MS

    • Rule: ^MS$

This satisfies the 3-character minimum while still matching MS precisely: nothing shorter, nothing longer, no partial matches.

Note: You don't need to manually select a rule type. Osano will automatically determine whether your pattern is an exact match, path match, or regular expression based on its structure.

Example: Scripts

You have 4 scripts that should all be classified as "Essential."

  • https://www.yourwebsitedomain.com/cdn/scripts.js

  • https://www.yourwebsitedomain.com/cdn/themes.js

  • https://www.yourwebsitedomain.com/cdn/images.js

  • https://www.yourwebsitedomain.com/cdn/documents.js

Instead of classifying each script individually, you can create a rule for their shared domain:

https://www.yourwebsitedomain.com/cdn/

This will capture all 4 scripts and auto-classify them as "Essential" when saved to Rules.

Example: Cookies

You have 4 cookies that all do the same thing and should all be classified as "Analytics."   

  • _cookie_bb_123

  • _cookie_bb_234

  • _cookie_bb_345

  • _cookie_bb_456

Instead of individually classifying each cookie, you can create a shared rule that captures all 4:

_cookie_bb_.*

This will capture all 4 cookies and auto-classify them as "Analytics" when saved to Rules. It will also auto-classify any similar cookies in the future.

Note: Sometimes multiple cookies from the same vendor will serve different purposes and thus will need different classifications for full compliance.


Adding a Script or Cookie Classification Rule from Scratch

If you already have scripts or cookies listed in the Rules tab

Scripts:

  1. In Consent Manager, go to the Script tab, then the Rules tab.

  2. Click the purple (+) icon.

  3. Insert text that is specific enough to identify only the grouping you wish to create.

  4. Click Save and Publish to make the rule take effect.

Once published, all scripts that match the criteria will automatically fall under the associated rule.

Note: Be specific with your pattern. Osano.js pattern matching is "greedy," meaning it looks for a match of the defined script name anywhere in the script's URL. For example, the script https://connect.facebook.com/scripts/analytics.js would be matched by analytics.js, connect.facebook.com, or even just https://. Being too broad may result in scripts being incorrectly categorized or blocked, so make your pattern as specific as possible.

Osano.js accepts Postgres POSIX-style regular expressions, but it's best to use regex characters sparingly. Accepted characters are subject to change in future product updates.

Cookies:

  1. In Consent Manager, go to the Cookies tab, then the Rules section.

  2. Click the purple (+) icon.

  3. Insert text that is specific enough to identify only the grouping you wish to create.

  4. Click Save and Publish to make the rule take effect.

Once published, all cookies that match the criteria will automatically fall under the associated rule.

If there are no scripts or cookies listed in the Rules section

If you don't yet have any script or cookie rules, add them ad hoc: go to the Scripts or Cookies tab and click Add Script Rule. The process is the same as above.


Creating Classification Rules Based on Discovered Scripts/Cookies

You can create script/cookie rules from the "Discoveries" tab as well.

Script/Cookie rules with suggested classifications can be edited inline and saved using the (floppy disk) icon. Once created, this rule will move into the Rules section.

Scripts/Cookies with no suggested rules or classifications will show "Unknown" in their classification dropdown. The usage and classification of these scripts and cookies must be identified within your organization. Once identified, you can modify the classifications and use the floppy disk icon. Once created, this rule will move into the Rules section.

Was this article helpful?
Subscribe to receive updates on this article