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.
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.
Then press Add a New Tag to configure Doofinder’s script.
In the next screen provide:
- A name for the new tag, for instance: Doofinder Script V7.
- 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.
- 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.
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.
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.
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:
- Choose the search engine you want to work on.
- Go to Configuration > Doofinder Layer > Setup.
- Click the Edit Script button.
- Add your custom template tags before the layer script and modify the script to use them in case it’s necessary.
- 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:
Remember to replace the placeholders in the URL by actual values:
- [zone]: Use
us1depending 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: firstname.lastname@example.org.