Civic tool example
From Wiki
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); }); }