npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@financial-times/ads-personalised-consent

v6.2.0

Published

ads-personalised-consent =================

Downloads

3,859

Readme

ads-personalised-consent

A client side package to provide consent settings of personalised advertisement.

Functionality Overview

This package collects all the information related to privacy and generates an answer on whether different types of personalised advertisement is allowed. It takes into account of:

  • The privacy policy of the location which the user is in (e.g. California Consumer Privacy Act (CCPA) for California, US), which is collected from Privacy Legislation Client
  • The browser settings - e.g. Global Privacy Control (GPC).
  • The consents settings for behavioral, demographic and programmatic ads retrieved via the FTConsent cookie. Users can configure these settings via the Manage Cookies page in FT.com, the Manage Cookies page on the FT App and the Manage Cookies pages on the specialist titles websites. These values can also be configured via the Cookie Banner displayed on FT.com, FT App or specialist titles. Yet another way to configure ads consent is via the Privacy page on FT.com

Use

Typical usage would be to add the module to your app, call the imported method and then check whether the personalised advertisement is allowed:

import { getPersonalisedConsent } from "@financial-times/ads-personalised-consent";

async function onPageLoad() {
  // create a fresh, updated instance of PersonalisedConsent, and get the privacy properties via getters
  const pc = await getPersonalisedConsent();
  const personalisedConsent = pc.isAllowed();
  // check whether a certain type of personalised ads is allowed or not
  if (personalisedConsent.behavioral) {
    setupBehavioralAds();
  } else {
    blockBehavioralAds();
  }
  
  // alternatively, only update the privacy legislation properties and retrieve the new values
  await pc.updatePrivacyLegislation();
  const legislation = pc.getLegislation();
  const region = pc.getRegion();
  // similar for GPC value and consent cookie
  pc.updateGpcValue();
  const gpc = pc.getGpcValue();
  pc.updateConsentCookie();
  const consentCookie = pc.getConsentCookie();
  ...
}

API

getPersonalisedConsent()

Initialise the instance of PersaonalisedConsent and update all the privacy related properties. Returns a Promise which always resolves with the said instance.

personalisedConsent.isAllowed()

Returns an Object identifying whether different types of personalised ads (behavioural, demographic and programmatic) are allowed or not, based on

  • The privacy policy obtained from Privacy Legislation Client (If Privacy Legislation Client returns error, it will consider the user is subject to all the policies available.)
  • The browser settings for Global Privacy Control (GPC)
  • The consents settings for behavioral, demographic and programmatic ads retrieved via the FTConsent cookie.

| Name | Data-structure | Notes | |-------------------|----------------------------|-------| | behavioral | boolean | whether behavioral ads is allowed | | demographic | boolean | whether demographic ads is allowed | | programmatic | boolean | whether programmatic ads is allowed |

personalisedConsent.getLegislation()

Returns the legislation stored in the instance since last update, which is either

  • a Set of legislation which the user is subject to if Privacy Legislation Client succeeds, or;
  • undefined if Privacy Legislation Client throws error.

personalisedConsent.getRegion()

Returns the region stored in the instance since last update, which is either

  • a string identifying the region which the user is in if Privacy Legislation Client succeeds, or;
  • undefined if Privacy Legislation Client throws error.

personalisedConsent.getGpcValue()

Returns a boolean showing the GPC settings on the browser (which is Navigator.globalPrivacyControl) stored in the instance since last update.

personalisedConsent.getConsentCookie()

Returns an Object identifying user's settings in FTConsent cookie for different types of personalised ads (behavioural, demographic and programmatic) stored in the instance since last update.

| Name | Data-structure | Notes | |-------------------|----------------------------|-------| | behavioral | boolean | FTConsent cookie exists and behaviouraladsOnsite:on is set | | demographic | boolean | FTConsent cookie exists and demographicadsOnsite:on is set | | programmatic | boolean | FTConsent cookie exists and programmaticadsOnsite:on is set |

personalisedConsent.update()

Update all the privacy related properties. Returns a Promise which always resolves.

personalisedConsent.updatePrivacyLegislation()

Updates only legislation and region, and returns a Promise containing

| Name | Data-structure | Notes | |-------------------|----------------------------|-------| | legislation | Set of string OR undefined | a Set of legislation which the user is subject to if Privacy Legislation Client succeeds, otherwise undefined | | region | string OR undefined | a string identifying the region which the user is in if Privacy Legislation Client succeeds, otherwise undefined |

personalisedConsent.updateGpcValue()

Updates only the GPC settings, and return a boolean showing the latest GPC settings on the browser.

personalisedConsent.updateConsentCookie()

Updates only the user's settings in FTConsent cookie for different types of personalised ads, and return an Object identifying the settings.

| Name | Data-structure | Notes | |-------------------|----------------------------|-------| | behavioral | boolean | FTConsent cookie exists and behaviouraladsOnsite:on is set | | demographic | boolean | FTConsent cookie exists and demographicadsOnsite:on is set | | programmatic | boolean | FTConsent cookie exists and programmaticadsOnsite:on is set |