Google Tag Manager

It is possible to add the JS Implementation to your platform using Google Tag Manager (GTM). The process of adding the JS Implementation using GTM is mostly similar to adding it regularly. However, instead of adding the snippets directly to the HTML, we need to add it in GTM using a Custom HTML tag.

To get started, create a new Tag in GTM with the type Custom HTML and trigger it on All Pages. Give the tag a descriptive name so that it is clear it contains the Tweakwise JS Implementation.

Next, copy the following snippet into the HTML text field and replace INSTANCEKEY with your own instance key. You can find it in the Tweakwise App under Connectivity > Endpoints.

  window.tweakwiseFailover = function (src) {
    var script = document.createElement("script");
    script.async = true;
    script.src = src;

Input & output

As described in the previous article, the JS Implementation will look for an input and an output. When adding the JS Implementation through GTM, this is no different. Please make sure the input and output elements have the correct id's.


If the input and/or output already have another id or you simply want to match on a different attribute we can change this in the JavaScript file.

Category pages


For this functionality you need to have a subscription for Level Medium or higher.

To enable category pages for your JS Implementation through GTM add the following snippet to the previously created Tag and replace CID with the id of the category you want to show.

  window["twn-starter-config"] = window["twn-starter-config"] || {};
  window["twn-starter-config"].navigation =  {
    cid: "CID" // <- Replace CID with the category id you want to show

For pages where you don't want to show a product lister page you can put this option on null. This is useful on for example the home page.


The snippet above is an example on how to add configuration locally.

For more information on adding configuration locally click here β†’