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

@tymate/react-quantcast

v0.2.1

Published

Quantcast Choice integration for React

Downloads

9

Readme

React Quantcast

A React provider to retrieve privacy and consent settings from an installed Quantcast Choice tag.

It integrates with the Consent Manager Platform API, which is an IAB standard to manage privacy settings.

Installation

Using yarn :

yarn add @tymate/react-quantcast

Reference

<TCFProvider />

TCFProvider integrates with the Quantcast CMP API to retrieve purposes allowed by the user and custom non-IAB vendors consent.

It takes the following properties :

  • customVendorsMapping, an optional object mapping custom vendor IDs defined in the Quantcast Choice interface to arbitrary strings.

The provider must wrap a children function having this signature

({purposes, customVendors}) => {}

Its parameter keys are :

  • purposes, an object mapping purposes asked by the website and the boolean value of user consent. This object can be passed to Google Tag Manager to define which purposes have been consented to.
    {
      "purpose.content_performance": false,
      "purpose.improve_products": true
    }
  • consentPurposes, an array of purposes consented by the user.
  • publisherPuproses, an array of purposes enabled in the Quantcast interface.
  • customVendors, an array of custom vendors enabled by the user.
import { TCFProvider, CONTENT_PERFORMANCE } from '@tymate/react-quantcast';
import { includes } from 'lodash';

<TCFProvider
  customVendorsMapping={{
    1: 'vendor.facebook',
    2: 'vendor.google_analytics',
  }}>
  {({ consentPurposes, customVendors }) => (
    <>
      {includes(consentPurposes, CONTENT_PERFORMANCE) && (
        <div>Content performance enabled, activating Google Analytics</div>
      )}
      {includes(customVendors, 'vendor.facebook') && (
        <div>Activating Google Pixel</div>
      )}
    </>
  )}
</TCFProvider>

TCFContext

TCFContext is a context having the same values as the object passed by <TCFProvider /> to its children function.

import React, { useContext } from 'react';
import { TCFContext, CONTENT_PERFORMANCE } from '@tymate/react-quantcast';

const Analytics = () => {
  const { consentPurposes } = useContext(TCFContext);

  return (
    <>
      {includes(consentPurposes, CONTENT_PERFORMANCE) && (
        <div>Content performance enabled</div>
      )}
    </>
  )
}

Constants

The library includes a bunch of constants you can use to reference TCF purposes.

The provided constants are :

  • STORE_DATA
  • BASIC_ADS
  • ADS_PROFILING
  • TARGETED_ADS
  • CONTENT_PROFILING
  • TARGETED_CONTENT
  • AD_PERFORMANCE
  • CONTENT_PERFORMANCE
  • MARKET_RESEARCH
  • IMPROVE_PRODUCTS

The library also exports a PURPOSES constant, which is a mapping between purposes IDs from Quantcast and their corresponding constants.

References