Custom Cookie Consent

Summary

PathFactory is able to integrate with external cookie consent providers. These may be custom solutions built by your organization, or a cookie consent provider you have purchased.

How does this work?

PathFactory allows 3rd party cookie consent providers to manage the PathFactory vid persistent cookie on a Content Track by providing a set of functions that can be executed within a Content Track. Working in conjunction with the scripts from your consent provider, these functions can determine the current status of cookie consent of a visitor and set the consent status of a visitor.

Note
Don’t have an external cookie consent provider? Use PathFactory’s built-in cookie consent function!

  1. Select Organization Settings from the drop-down menu under your username.
    Note
    You must be an admin user to access Organization Settings.

    imageOrganization Settings

  2. Click the Cookie Consent tab, then select Enable Custom Cookie Consent.
    imageEnable Custom Cookie Consent

  3. In the text box, enter scripts from your consent provider in conjunction with PathFactory consent functions.
    Note
    See the Code Samples below on how to use setPfConsent() and pfConsentStatus() with a 3rd party consent provider.

    imageCode Example

  4. (Optional) Check Apply Cookie Consent to all new tracks.
    Note
    This ensures that all new Content Tracks created after this point will automatically have Cookie Consent toggled on. If you do not select this option, you will have to manually toggle on Cookie Consent for individual Content Track.

    imageApply Cookie Consent to all new tracks


Code Sample: Generic Implementation

If you are using a custom cookie consent implementation on your website, you can use the function below to interact with PathFactory’s consent settings.
Your consent provider scripts should request tracking consent from the visitor and pass the result to the setPfConsent function.

//Add the script for your consent provider here

function setPfConsent(status){
if(pfConsentStatus()!=true &&status==true)
    return pfCookieResponse(true);
if (pfConsentStatus() != false && status==false)
    pfCookieResponse(false);
}

pfOnJukeboxLoad.then(function() {

//run consent functions here.
If your consent manager returns true,
run setPfConsent(true), 
if it returns false, run setPfConsent(false) });

Code Sample: TrustArc Implementation

The TrustArc script contains 2 parts.
First, PathFactory checks consent from TrustArc when the Content Track loads.
PathFactory then adds a listener to check again if a visitor updates their preferences in TrustArc on the Content Track.
We are getting the visitor’s consent status from the notice_gdpr_prefs cookie dropped by TrustArc.

Add the following scripts to the text area in the Cookie Consent configuration section:

<script async="async" type="text/javascript" src='//consent.truste.com/notice?domain=YOURDOMAIN.com&c=teconsent&text=true'; crossorigin></script>

<script>
//Level of consent required: 0=required, 1=functional, 2=advertising
var cookieCategory = 2;

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

function setPfConsent(status){
if(pfConsentStatus()!=true &&status==true)
    return pfCookieResponse(true);
if (pfConsentStatus() != false && status==false)
    pfCookieResponse(false);
}


pfOnJukeboxLoad.then(function() {
  setPfConsent(getCookie("notice_gdpr_prefs").indexOf(cookieCategory)>=0);
});
//Register with the API for automatic updates of user preferences (for the settings you care about)
//--OR-- if the API is loading, then this will send an update when the API is done and has loaded the user preferences.
      window.addEventListener("message", function(e){
          try{
            var json = JSON.parse(e.data);
                        if (json.source=="preference_manager"&&json.message=="submit_preferences"){
                      setPfConsent(getCookie("notice_gdpr_prefs").indexOf(cookieCategory)>=0)
           }
           }catch(e){}
           }, false);
  </script>

Code Sample: CookiePro Implementation

The CookiePro script dynamically updates script tags in the HTML tied to the different cookie categories. Simply add the script tag below along with the CookiePro banner script. When the visitor has consented to being tracked, the script tag’s type will change from text/plain to JavaScript and the PathFactory opt-in will execute.

Add the following scripts to the text area in the Cookie Consent configuration section:

<script type="text/plain" class="optanon-category-2">

pfOnJukeboxLoad.then(function() {
if(pfConsentStatus()!=true)
 pfCookieResponse(true);
});
</script>

In order for these cookie consent scripts to execute, a Content Track must have Cookie Consent toggled On.
imageCookie Consent toggle

Updated on April 13, 2023

Was this article helpful?

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT