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.
Comments
2 comments
Hi, I'm not a developer so I'm just trying to understand this in simple terms! At the moment, on the site I look after, we have a Tripadvisor widget that loads in the footer showing reviews. By adding prior consent as a 'Marketing' cookie, does this mean that the widget will not show/be loaded until the 'Marketing' consent box is ticked by the user?
Excuse my ignorance, but I'm guessing the box/widget can't be loaded and the cookies turned off (until consent given). Can you have the review box showing without loading cookies?
Hi, i've just try this solution but the widget don't loading properly, only the image is loaded after accept marketing-cookies. I using it in wordpress widget. Is there any other solution that can be used?
Please sign in to leave a comment.