Script Pattern Matching

Identifying Scripts

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

For the sake of compliance, each script should be classified as one of the following: Essential, Marketing, Analytics, Personalization, Blacklisted. (See " Classification Categories" for more info on these classification types.)

Generally, any script that is required for your site to function (meaning navigation, scrolling, animations, content loading) are 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 loading from the same domain that can all be classified with the same category. 

Osano.com, for example, uses Facebook advertising and embed facebook JS tracking scripts. For our own internal use, it made sense to categorize the entire facebook.com domain as Marketing to ensure only users who have consented to "Marketing" load those 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. 


Adding a Script Classification Rule

In Consent Manager, from the "Script Classification" tab, click "Add +" 

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

  • The osano.js pattern matching is "greedy" meaning it looks for a match of the defined script name in the script URL on the page. Thus the script https://connect.facebook.com/scripts/analytics.js would be matched by analytics.js or connect.facebook.com or https:// - therefore it is important that if you edit the script matching pattern in the Osano CMP that you be as specific as possible, being too broad in your matching may result in scripts being incorrectly categorized or blocked.
  • The Osano.js pattern matching does not interpret all regular expressions and it is recommended that regex characters be used sparingly. These accepted characters are subject to change in future iterations of the product.
    • Accepted regex characters:
      • * 0, one, or, more of the preceding character
      • +  one or more occurrence of the preceding character
      • ^ denotes the beginning of a regular expression
      • $ denotes the end of a regular expression
      • () check for string

Once the text is in place, press the tab key on your keyboard to see the rule take effect (all scripts that match the criteria will move underneath the associated rule).

Below is an example of a functioning set of patterns that are classified on Osano.com - some are matched by broad rules, others are more specific.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.