How to Allow Content in Some Pages Using GTM after Cookie Consent
Often you'd want to allow some content only in a subset of your web pages and only after the visitor accepts cookies.
For example, let's say you want to add the toolbar with sticky share buttons provided by sharethis.com only to blog pages of your site and only if the visitor has already accepted cookies.
To achieve this, you will need a new GTM tag that will load the toolbar only when the following two conditions are true at the same time :
- The visitor accepted Vine cookies. That means that the Vine cookie_consent trigger has already fired.
- The visitor is in a blog page. For this we will need a new Blog Trigger that will fire when a blog page is opened.
Here is how you can do this:
To "mark" all pages where you want the toolbar to appear, you can add the following script to all blog pages so that they send a "blog" GTM event when opened:
- Create a GTM "Blog" trigger as follows.
- To verify that both triggers fired, create a GTM group trigger as follows:
- Create a GTM tag as follows using the script provided by sharethis.com
Sending GTM Event for Subset of Pages
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({'event': 'blog'});
</script>
It will fire when the visitor opens a blog page which sends the "blog" event:
This group trigger will fire only after both included triggers have fired.
This tag will load the ShareThis toolbar only when both triggers have fired which means that the visitor has already accepted cookies and opened a blog page:
Comments
0 comments
Please sign in to leave a comment.