The TripAdvisor Widget consists of two cookie-setting elements:
1. An image
2. A script
To prevent each element from setting cookies prior to the users consent, we have to mark up the elements.
Below, the img tag is marked up with the data-src attribute, rather than src.
The script tag gets the TripAdvisor javascript, and waits until it is loaded, before rendering it.
Normally it is sufficient to mark up a script tag with <script type="text/javascript" data-cookieconsent="marketing">
, however, in the case with TripAdvisor, it won't work, because TripAdvisor is executed after the site has loaded (window.onload) - the problem is, that Cookiebot executes after the event, which means we need to use a callback (waitForTripAdvisor function).
We have placed additional <div> placeholders, to give the users ability to change their consent, in order to view the Widget. You can style this however you like.
<div id="TA_rated9" class="TA_rated cookieconsent-optin-marketing">
<ul id="cEEerS4Y0RA5" class="TA_links GQUyDNk">
<li id="ZBlQhNTUC2" class="2rx1dG9">
<a target="_blank" href="https://www.tripadvisor.it/">
<img data-src="https://www.tripadvisor.it/img/cdsi/img2/badges/ollie-11424-2.gif"
data-cookieconsent="marketing" alt="TripAdvisor"/>
</a>
</li>
</ul>
</div>
<script>
function waitForTripAdvisor() {
if (typeof window.taValidate !== "undefined") {
window.taValidate();
} else {
setTimeout(waitForTripAdvisor, 100);
}
}
</script>
<script type="text/plain" data-cookieconsent="marketing">
Cookiebot.getScript("https://www.jscache.com/wejs?wtype=rated&uniq=9&locationId=4375382&lang=it&display_version=2", false, function() { waitForTripAdvisor(); })
</script>
<div class="cookieconsent-optout-marketing">
Please <a href="javascript:Cookiebot.renew()">accept marketing-cookies</a> to view TripAdvisor.
</div>
Source: GitHub
Comments
0 comments
Please sign in to leave a comment.