Deploy widget with Google Tag Manager
2 min
You can deploy recommendation widgets using Google Tag Manager (GTM). This method is useful for adding widgets without modifying your site's codebase.
Prerequisites
- The ip.js tracking script must be installed on your site, either directly or through a separate GTM tag that fires before the widget tag.
Deploy widget tag
- Create a tag – Create a new tag in your GTM workspace.
- Configure the tag – Complete the following:
- Choose Custom HTML as the tag type.
- Paste the widget script code into the HTML field. Replace YOUR_DELIVERY_KEY with your actual key.
<script class="idio-recommendations" type="text/x-mustache" data-api-key="YOUR_DELIVERY_KEY">
{{#content}}
<div class="idio-recommendation">
{{#main_image_url}}
<a href="{{link_url}}"><img src="{{main_image_url}}?w=150&h=150" class="image" /></a>
{{/main_image_url}}
<h3><a href="{{link_url}}">{{title}}</a></h3>
<p>
{{abstract}}
<a href="{{link_url}}">Read more...</a>
</p>
</div>
{{/content}}
</script>- Configure the trigger – Set the trigger to fire on the specific pages where you want the widget to display. You can use a Page View trigger with conditions based on the Page Path.
- Save and publish – Save your tag and publish the GTM container.