Integrating Doofinder using the Google Tag Manager (GTM) allows you to manage your script without touching your site’s HTML code. 

To integrate it this way, follow these steps:

  1. Create your GTM account or log in if you already have one.
  2. Select the workspace where you’re going to add the new script.

  1. Select Add a New Tag to configure Doofinder’s script. 
  1. On the next screen, provide the following:
  • A name for the new tag, for instance: Doofinder Script V7
  • Inside the Tag Configuration, ensure that the tag type is Custom HTML and paste your script for Doofinder inside the HTML editor, including the surrounding script tags.
  • Then under Triggering, you may choose when the script must be activated. Note that the recommended option is All Pages. This way, Doofinder will be available on all pages. 
  1. Once done, press Save and your HTML tag will be created. 
  2. Back in your GTM dashboard, press the Submit button in the top right corner.
  1. Next, select Publish and Create Version, then provide a relevant version name and description for the records, choose the environment where you want to publish the changes and press the Publish button in the top right corner.
  1. You will be able to see the details of the latest published version from the dashboard. The Doofinder layer should be working as soon as the information reflects the latest version.

Custom templates and GTM

It is possible to customise Doofinder’s layer templates in Google Tag Manager.

To do this, you will need to add the custom templates through Doofinder’s admin by editing the script. This is because GTM does not allow the use of Mustache JS templates inside the tags, so you cannot directly paste them as you did with the script earlier on.

Therefore to customiSe the template and GTM, use the following steps:

  1. Select the search engine you want to work on. 
  2. Go to Configuration > Doofinder Layer > Setup.
  3. Click the Edit Script button.
  4. Add your custom template tags before the layer script and modify the script to use them if necessary.
  5. Save your changes.

Now you only have to publish a new version of your Doofinder layer tag in GTM, with much simpler content such as this:

<script
  type="text/javascript"
  src="//[zone]-search.doofinder.com/5/script/[hashid].js">
</script>


Remember, the placeholders in the URL must be replaced by actual values:

  • [zone]: Use eu1 or us1 depending on your search engine’s zone.
  • [hashid]: Your search engine’s unique ID.

If you publish your layer this way, the actual script will be served by Doofinder instead, so you will have to perform any modifications directly from Doofinder’s Admin. No further action in GTM will be required.

Should you encounter any problems, please contact support@doofinder.com

Last Updated: July, 2021