1. Home
  2. Google Tag Manager
  3. Survey integration with Google Tag Manager

Survey integration with Google Tag Manager

With Google Tag Manager it is possible to integrate surveys into websites without changing the websites code. This is valuable if the survey changes frequently or the integration scenarios are complex. One example for a complex setup is page or country based surveys.

Timer triggered survey

Timer triggers are used if a survey shall be displayed after some amount of time. To achieve this, the following steps need to be configured:

Create a timer with the desired delay (interval) and a limit of 1. The timer could be restricted to dedicated pages or to an entire host, like shown in the image below

Google Tag Manager Time Trigger

Create a custom HTML Tag. HTML shall not be written directly, but a Script-Tag needs to be created to inject the HTML using JavaScript. The reason is that it is possible with JavaScript to inject the HTML at a specific position. Also the desired HTML code needs to be minified. To minify the code the following tool can be used. The image below shows the usage of jQuery to inject a popup containing a survey in a div called “content” and shows the popup. The detail of this code snippet is explained here.

Google Tag Manager Custom HTML Block which injects a popup.

Button triggered survey

To inject a button with an action the following steps need to be followed:

Create a page load trigger which is fired when the webpage has been loaded.

Google Tag Manager Page Load Trigger

When this trigger is fired the following tag is needed to create the button as well as the popup.

Google Tag Manager Custom HTML Block which injects a button with a popup.

As a next step the click trigger needs to be defined and wired to the ID defined on the button.

Google Tag Manager Trigger to attach a click event.

Finally another HTML Tag is needed which is fired by the click trigger. On the click the popup is opened.

Google Tag Manager Custom HTML Block to open a popup.

Of course the wiring of the click event can be implemented also in the JavaScript of the first custom HTML Tag. The advantage of this split is the automatic tracking how many visitors click on the button.

Page specific survey

For page specific surveys a page view trigger is needed. In the image below it has been configured for the “sales” page.

Google Tag Manager page load trigger with page filter.

The custom HTML Tag to inject the survey is the same as for the previous scenarios.

Country specific survey

Google Tag Manager doesn’t support Country, Region or City specific Triggers by default. Nevertheless there are providers like IPInfo which provides location information based on the IP address. To integrate this into Google Tag Manager the following steps are required:

Create a page load trigger.

Google Tag Manager page load trigger without filter.

In the Custom HTML Tag the call to IPInfo has to be implemented and the response needs to be evaluated. The Service returns country, region and city as well as other attributes. These attributes need to be used to distinguish he location based survey as shown in the switch statement of the following image.

Google Tag Manager custom HTML to inject location specific code.
Updated on January 17, 2024

Was this article helpful?

Need Support?
Can't find the answer you're looking for?
Contact Support