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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adv-re/universal-consents-cookies-widget

v1.20.0

Published

A widget for cookie consent management and Segment configuration, compatible with TCF. It includes the Adevinta Real Estate Segment Wrapper by default.

Downloads

636

Readme

@adv-re/universal-consents-cookies-widget Build Status

A widget for cookie consent management and Segment configuration, compatible with TCF. It includes the Adevinta Real Estate Segment Wrapper by default.

A full example is available here.

Getting Started

Add third-party scripts

Insert the following scripts into the <head> of your HTML document.

<!-- Segment -->
<script>
  !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";

  analytics.load("YOUR_WRITE_KEY");  // your write key must be set here
  }}();
</script>

<!-- TCF -->
<script type="text/javascript">
(function(){function i(e){if(!window.frames[e]){if(document.body&&document.body.firstChild){var t=document.body;var n=document.createElement("iframe");n.style.display="none";n.name=e;n.title=e;t.insertBefore(n,t.firstChild)}else{setTimeout(function(){i(e)},5)}}}function e(n,o,r,f,s){function e(e,t,n,i){if(typeof n!=="function"){return}if(!window[o]){window[o]=[]}var a=false;if(s){a=s(e,i,n)}if(!a){window[o].push({command:e,version:t,callback:n,parameter:i})}}e.stub=true;e.stubVersion=2;function t(i){if(!window[n]||window[n].stub!==true){return}if(!i.data){return}var a=typeof i.data==="string";var e;try{e=a?JSON.parse(i.data):i.data}catch(t){return}if(e[r]){var o=e[r];window[n](o.command,o.version,function(e,t){var n={};n[f]={returnValue:e,success:t,callId:o.callId};if(i.source){i.source.postMessage(a?JSON.stringify(n):n,"*")}},o.parameter)}}if(typeof window[n]!=="function"){window[n]=e;if(window.addEventListener){window.addEventListener("message",t,false)}else{window.attachEvent("onmessage",t)}}}e("__tcfapi","__tcfapiBuffer","__tcfapiCall","__tcfapiReturn");i("__tcfapiLocator")})();
</script>

Basic global configuration

Place this script after the third-party scripts and before the widget script.

<script>
  window.__SEGMENT_WRAPPER = {
    ADOBE_ORG_ID: "05FF6243578784B37F000101@AdobeOrg",
    TRACKING_SERVER: "schibstedspain.d3.sc.omtrdc.net",
  };
  window.__mpi = window.__mpi || {};
  window.__mpi.segmentWrapper = {};
  window.__mpi.universalConsentsCookiesWidget = {};
</script>

Widget Configuration

Customize the widget by setting options in window.__mpi.universalConsentsCookiesWidget.

<script>
  window.__mpi.universalConsentsCookiesWidget = {
    cookiePolicyUrl: 'https://your-domain.com/cookie-policy?disable-cmp',
    logo: 'https://your-domain.com/logo.png',
    site: 'fotocasa'
  }
</script>
<script defer src='https://unpkg.com/@adv-re/universal-consents-cookies-widget/umd/index.js'></script>

Segment Wrapper configuration

Customize the segment wrapper by setting options in window.__mpi.segmentWrapper.

<script>
  window.__mpi.segmentWrapper = {
    defaultContext: {
      vertical: "realestate",
      site: "<site>",
    },
    defaultProperties: {
      language: "<language>",
      vertical: "realestate",
      site: "<site>",
    },
    googleAnalyticsMeasurementId: '<api-key>'
    importAdobeVisitorId: true,
    sendXandrId: true,
    isUserTraitsEnabled: true,
  }
</script>

Add widgets scripts

<script
  defer
  src="https://unpkg.com/@adv-re/universal-consents-cookies-widget/umd/index.js"
></script>
<link
  rel="stylesheet"
  href="https://unpkg.com/@adv-re/universal-consents-cookies-widget/umd/styles.css"
/>

Add widget tag

Inside the <body> add a tag where the widget will be rendered.

<div id="adevinta_consents_cookies_universal_widget"></div>

Link to open the widget

You must offer to the user the possibility to open the widget to change the consents anytime. For that, you could add this HTML in order to give this feature to the user.

<a
  href="#"
  alt="Gestionar consentimientos de cookies"
  onclick="window.__callUniversalConsentsCookiesWidget()"
  >Gestionar consentimientos de cookies</a
>

Load Scripts based on user consents

Once the consent widget is implemented on your site, you can dynamically load third-party scripts only after the user has granted the necessary consents.

This allows you to remain compliant with privacy regulations while deferring non-essential scripts until the appropriate permissions are given.

Use the following example to load specific vendors only when the user consents to the required purposes.

<script>
  // init vendors loader by consents
    window.onload = () => {
      window.sui.vendors.initVendorConsentsLoader({
        vendors: {
          tealium: {
            // script to load
            script: 'https://frtassets.fotocasa.es/external-scripts/utag-pro.js',
            // consents needed for this script
            consents: {
              purposes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
              specialFeatureOptins: [1]
            }
          },
          addThis: {
            // script to load
            script: 'https://www.addthis.com/script.js',
            // consents needed for this script
            consents: {
              purposes: [1], // example of a script with a single purpose
              specialFeatureOptins: [1]
            }
          }
        }
      })
    }
</script>

Please, keep in mind that if the user doesn't provide needed consents the script won't be loaded.

Check list of purposes by ID..