InteractiveAdvertisingBureau / Global-Privacy-Platform

IAB Tech Lab Global Privacy Platform specification
72 stars 36 forks source link

parsedSections in pingReturn object #80

Closed lamrowena closed 1 year ago

lamrowena commented 1 year ago
janwinkler commented 1 year ago

with the parsedSection(s) (singular or plural?) object in there, we can adjust the last example to this:


 if (__gpp)
 {
  __gpp('addEventListener', function (evt, success)
  {
   //callback will receive all events, we only want to react on signalStatus ready events
   if (evt.eventName !== 'signalStatus' || evt.data !== 'ready')
   {return;}

   //if only the GPP String is needed, it can be taken directly from pingData.gppString
   var gppString = evt.pingData.gppString;

   //get the data from the TCF Canada section
   //Note: You might also want to check if Canda is in the pingData.applicableSections 
   if ('tcfcav1' in evt.pingData.parsedSections) 
   {
    var data             = evt.pingData.parsedSections.tcfcav1;
    var vendorConsent    = data[0].VendorExpressConsent;
    var vendorImpConsent = data[0].VendorImpliedConsent;
    var purposeConsent   = data[0].PurposesExpressConsent;
    // ... do something Canadian !
   }
  });
 }