Civic tool example

From Wiki

Jump to: navigation, search

The cookie tool makes it easy to manage consent for different tech partners in a single tool.

We've prepared an example of how you could implement the Awin consent signals with this tool.

This is an example configuration.

name: 'Awin',
        label: 'Awin Tracking',
        description:
        'Our site is supported by advertising revenue. If a user of our site clicks a ' +
        'link to an external site, we may receive commission for referring that user. ' +
        'We may also receive a commission if an ad is presented to you. We and our service ' +
        'providers use small text files called cookies, and similar technology, on your device ' +
        'to understand the referrals we’ve made and whether an ad was shown. These cookies do ' +
        'not reveal your identity, web use or other behaviour.',
        cookies: [],
        onAccept: (): void => {
          this.findLinksAndAppend('awin1.com', 'cons=1');
          this.findLinksAndAppend('zenaps.com', 'cons=1');
        },
        onRevoke: (): void => {
          this.findLinksAndAppend('awin1.com', 'cons=0');
          this.findLinksAndAppend('zenaps.com', 'cons=0');
        },
      },


This function needs to be appended in your script tag as well in order for it to work.

public findLinksAndAppend(domain: string, param: string): void {
    const links: Element[] = sizzle('a[href*="' + domain + '"]');
    links.forEach((value: Element) => {
      let hrefValue: string = value.getAttribute('href');
      hrefValue = hrefValue.replace(/&cons=[0-9]/, "");
      const pPos: number = hrefValue.indexOf('p=');
      let newValue: string;
      if (pPos > -1) {
        const b4P: string = hrefValue.substr(0, pPos - 1);
        const afterP: string = hrefValue.substr(pPos - 1, (hrefValue.length - pPos) + 1);
        newValue = b4P + '&' + param + afterP;
      } else {
        newValue = hrefValue + '&' + param;
      }
      value.setAttribute('href', newValue);
    });
 
  }

Privacy

Due to new European legislation regarding how websites store information about you, AWIN is updating its privacy policy. You can see the new version of our policy here. If you would like to see the information we capture on this website, please click here for further details. In order to accept cookies on this site please click the 'I ACCEPT' button