On every plan, including Free

Google Tag Manager

Surveys as a GTM tag.

Add UserLoop as a Custom HTML tag on the All Pages trigger and publish the container. The site's own code does not change, and your other tags can open a survey or pass it data.

Read the docs
One tag, one trigger. Sets no cookies.
13 KBloaded by the tag, gzipped
6survey triggers
12methods your tags can call

How do I add a survey with Google Tag Manager?

In UserLoop, choose Google Tag Manager under Your site is built with and copy the code. In Tag Manager, open Tags and choose New, pick Custom HTML as the tag type and paste the code. Set the trigger to All Pages, save, then Submit and Publish the container. Open any page of the site and UserLoop marks the survey Live. Nothing in the site's own code changes.

Tag type
Custom HTML
Trigger
All Pages
Then
Submit and Publish the container
Plans
Free, Unlimited and Plus

Install

One tag, one trigger, one publish

In UserLoop, open the survey's Launch stage, set Your site is built with to Google Tag Manager and copy the code. Then:

  1. 01

    Create a Custom HTML tag

    In Google Tag Manager, open Tags and choose New. Choose Custom HTML as the tag type and paste the code.

  2. 02

    Trigger it on All Pages

    Set the trigger to All Pages. The tag runs once per page load, and UserLoop follows any route changes after that by itself.

  3. 03

    Submit and publish

    Save the tag, then Submit and Publish the container. Open a page of the site and UserLoop shows Live with the address it saw.

The tags

The Custom HTML to paste

The first tab is the whole install. The others are optional tags that use what Tag Manager already knows about the visit.

<!-- Tag type: Custom HTML. Trigger: All Pages. -->
<script>
!function(w,d,o){if(w.userloop)return;var q=[],u=w.userloop={q:q};"init identify setAttributes track page show close reset setLanguage on off".split(" ").forEach(function(m){u[m]=function(){q.push([m,[].slice.call(arguments)])}});var s=d.createElement("script"),c=d.currentScript;s.async=1;s.src="https://cdn.userloop.io/sdk-3/userloop.js";if(c&&c.nonce)s.nonce=c.nonce;d.head.appendChild(s);u.init(o)}(window,document,{"siteKey":"YOUR_SITE_KEY"});
</script>
Tag Manager gets the loader, which defines userloop at once and queues calls until the SDK has loaded.

In your container

What Tag Manager adds to a survey install

The snippet is the same one every site uses. Running it from a container gives you three things a pasted tag does not.

Triggers

Any GTM trigger can open a survey

You already have triggers for form submissions, clicks and custom events. A one-line tag turns any of them into the moment a survey appears.

  • On an event. Set the survey's trigger to On an event with a name such as checkout_started. A tag that calls userloop.track with that name opens it.

  • Visitor attributes. Pass data layer variables with userloop.setAttributes, up to 50 of them, and target a survey on their values.

  • Rules still apply. The survey's pages, visitor rules and how often it shows are still checked before it opens.

Every SDK method

No deploy

Install without a release, and check it worked

Marketing can add UserLoop without waiting for a code change, and UserLoop confirms the install from real page loads.

  • Published containers only. The tag reaches visitors once the container is submitted and published. Until then UserLoop shows Needs setup.

  • Check installation. Select I've added it and UserLoop watches for your site, then shows Live and the address it was installed on.

  • One copy. If the snippet is also in the site's code, the second copy on a page does nothing.

GA4 events

Import a container for the way back

With the Google Analytics integration on, UserLoop pushes 4 survey events to the data layer, and gives you a container that turns them into GA4 events.

  • Download and Merge. Import the UserLoop container into your web container using Merge. It has a custom event trigger per event, a data layer variable per parameter and a GA4 event tag each.

  • One constant to set. Set UserLoop - GA4 Measurement ID to your web stream's G- ID.

  • Choice labels and scores only. Written answers, emails and other typed values are never pushed.

Google Analytics integration
window.dataLayer
// Pushed by UserLoop when "Send website events to the data layer" is on
dataLayer.push({
  event: "userloop_question_answered",
  survey_id: "SURVEY_ID",
  survey_title: "How did you hear about us?",
  question_id: "QUESTION_ID",
  response_id: "RESPONSE_ID",
  answer: "Podcast",
  score: undefined
});

// The other events:
// userloop_survey_shown
// userloop_survey_completed
// userloop_survey_dismissed
The Google Analytics and Tag Manager integration is on Unlimited and Plus. Use the data layer or gtag, not both, or each event is counted twice.

Platform facts

UserLoop in Tag Manager, in one table

Tag type
Custom HTML, holding the loader snippet
Trigger
All Pages
To go live
Save, then Submit and Publish the container
Gallery template
None. UserLoop uses a Custom HTML tag, and the importable container is for the GA4 event tags
Works on
Any site that loads your container, whatever it is built with
Single-page navigation
Route changes are detected from the History API. No History Change trigger is needed
Content Security Policy
Allow cdn.userloop.io for scripts, and s.userloop.io, data.userloop.io and survey-views.userloop.io for connections
Consent
Sets no cookies. Storage can start as memory only and move to local storage after consent
Page weight
13 KB gzipped per page load. A further 24 KB only when a survey shows

Frequently asked questions

Can I add a survey to my site with Google Tag Manager?

Yes. Add UserLoop's code as a Custom HTML tag with the All Pages trigger, then Submit and Publish the container. Every website survey you publish in UserLoop then shows through that one tag.

Is there a UserLoop template in the Tag Manager gallery?

No. The install is a Custom HTML tag you paste. UserLoop does offer a container to import, which holds the triggers, variables and GA4 event tags for survey events.

Can a GTM trigger open a survey?

Yes. Set the survey's trigger to On an event and give it an event name. A Custom HTML tag that calls userloop.track with that name, fired by any GTM trigger, opens the survey for visitors its rules allow.

Does it work on a single-page app through Tag Manager?

Yes. The tag runs once on the All Pages trigger, and the SDK then watches the History API for route changes. You do not need a History Change trigger, and a second copy of the snippet on a page does nothing.

Can survey activity go to Google Analytics 4?

Yes, on Unlimited and Plus. UserLoop pushes 4 events to the data layer, from survey shown to survey completed, and the importable container sends them to GA4. Written answers and emails are never included.

Do I need a developer?

Not for the install. If you can create a tag and publish a container, you can add UserLoop. A developer is only needed if the site sends a Content-Security-Policy that has to allow UserLoop's addresses.

Will the tag slow my pages down?

The loader is 13 KB gzipped and loads asynchronously. The code that draws a survey is a further 24 KB and is fetched only when a survey is about to show.

Is it free?

Website surveys are on every plan, including Free. Free allows 1 live survey with 3 questions and 50 responses a month. Unlimited is $19 a month with unlimited responses.

Keep reading

Add one tag to your container and publish

Start on the Free plan: 1 live survey, 3 questions and 50 responses a month.