How to integrate Doofinder using GTM

or send an email to support@doofinder.com

Integrating Doofinder using Google Tag Manager is quite simple and allows you to manage your script without touching your site’s HTML code.

Let’s see the steps required to have Doofinder working in your site.

Default integration

If you don't plan to perform any customization that involves templating, this is the easiest way to proceed.

First of all access your account in Google Tag Manager and choose the Workspace where you’re going to add the new script.

Accounts List

Then press Add a New Tag to configure Doofinder’s script.

Add a New Tag

In the next screen provide:

  1. A name for the new tag, for instance: Doofinder Script V7.
  2. Inside 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.
  3. Inside Triggering you may choose when this script must be activated. The default, recommended value is All Pages. This way Doofinder will be available in all pages.

Tag Configuration

Once done, press Save and your HTML tag will be created.

Back in the main dashboard, the next step is to publish this new tag. To publish our changes press the Submit button in the top right corner.

Submit Changes

In the next screen, choose Publish and Create Version and provide a meaningful 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.

Publish Version

In the dashboard you will be able to check the details of the latest published version. Doofinder layer should be working as soon as this information reflects the latest changes done.

Custom templates and GTM

Is it possible to customize Doofinder layer templates in Google Tag Manager? Yes, but a new approach is required: unfortunately Google Tag Manager does not allow to use Mustache JS templates inside tags so you can’t directly paste them as we did with the script.

Instead of adding custom templates in Google Tag Manager, we’ll add them in Doofinder Admin by editing our script:

  1. Choose 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 in case it’s necessary.
  5. Save your changes.

Now you only have to publish a new version of your Doofinder layer tag in Google Tag Manager, but now the content of the tag is much simpler:

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

Remember to replace the placeholders in the URL 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 the Doofinder Admin, no further action in Google Tag Manager will be required.

If you need help drop us an email to: support@doofinder.com.