Skip to content
Speak to us

Could your website be working harder for you?

How to Build a Website Survey Using GA4 and A/B Testing

November 20, 2026 Charlie Tait

You don't necessarily need a dedicated survey platform to collect feedback from your website visitors. If you already have an A/B testing tool and GA4, you have most of what you need to build a simple website survey and understand the responses.

In this guide, we'll walk through how to build a survey using your A/B testing platform, send the responses into GA4 and make sure you can actually use the data you've collected.

Building your survey in an A/B testing platform

The first step is to build the survey itself. 

You can use the visual editor or code editor build the survey using HTML, CSS and JavaScript within your testing platform. This could include multiple-choice questions, radio buttons, checkboxes, a progress indicator and a submit button.

Then, you can control when and where the survey appears using the targeting and triggering capabilities of your testing platform.

For a straightforward survey, you might have:

  • An introduction: Explain what the survey is about and how long it should take.
  • The questions: Display one question at a time, or show several together.
  • Answer options: Use predefined answers wherever possible to make reporting easier.
  • A completion step: Thank the user for taking part.

Understanding how GA4 collects survey responses

Once you've built your survey, you'll need a way to capture what users do with it.

This is where GA4 comes in.

If you're familiar with GA4, you'll know that almost everything is measured through events. Each event can also carry additional information, known as parameters, which help explain what happened.

For example, rather than simply recording that someone interacted with a survey, you could capture:

  • Which survey they interacted with.
  • Which question they were answering.
  • Which answer they selected.
  • Whether they completed the survey.

For our survey, we'll be using GA4 custom events because we want to capture information specific to the questions and answers we've created.

Sending survey events from your A/B testing platform to GA4

If your website uses Google Tag Manager, then the best approach is to push they survey events from the testing platform and into the dataLayer. Here's an example of a helper function you could add to the code editor in your A/B testing platform:

const pushToDataLayer = (event, parameters) => {
  try {
    window.dataLayer = window.dataLayer || [];

    window.dataLayer.push({
      event: event,
      ...parameters
    });

  } catch (error) {
    console.error("Survey tracking failed:", error);
  }
};

You can then call this function whenever someone interacts with the survey.

For example, when someone selects an answer:

pushToDataLayer("survey_answer", {
  survey_name: "exit_survey",
  question_number: 1,
  question_name: "reason_for_leaving",
  answer_value: "high_delivery_cost"
});

In GTM, you would create a Custom Event trigger listening for survey_answer, then configure a GA4 Event tag to send the event and its parameters to your GA4 property.

You would repeat this process for the other survey interactions.

Deciding which survey events to collect

Before adding tracking to your survey, it's worth agreeing on what you actually want to measure.

You don't need a separate event for every question or every possible answer. Instead, use a small, consistent set of event names and pass the question and answer details through as parameters.

For example, I'd recommend the following:

Event nameWhen it firesExample parameters
survey_impressionWhen the survey is first displayedsurvey_name
survey_question_viewedWhen a question is displayedsurvey_name, question_number
survey_answerWhen an answer is selectedsurvey_name, question_number, answer_value
survey_completeWhen the user submits the completed surveysurvey_name

This gives you a consistent tracking structure that you can reuse across different surveys.

For example, if you build three different surveys, you don't need to create twelve different event names. You can reuse the same four events and distinguish between surveys using the survey_name parameter.

Sending experiment and variation details

One of the benefits of building your survey within an A/B testing platform is that you can also understand how responses differ between variations.

For example, imagine you're testing two different versions of a product page and want to understand whether one gives users more confidence to purchase.

Most A/B testing platforms offer a native GA4 integration or another way to pass experiment and variation information into analytics.

Make sure you're capturing the experiment ID and the variation a visitor actually experienced, rather than simply recording that they've qualified for the test.

GA4 has supported experiment-related measurement conventions, including experience_impression and exp_variant_string, although the implementation depends on the platform and integration being used.

The important thing is to make sure your survey responses can be connected back to the correct experiment and variation.

This allows you to go beyond simply understanding what users think and start comparing how different website experiences influence their responses.

Naming rules and limits

There are also a few GA4 limitations to keep in mind:

  • Event names must follow Google's naming rules, including character and length restrictions.
  • Events can have a maximum of 25 parameters.
  • Custom parameters need to be registered as custom dimensions or metrics if you want to use them in standard reports and Explorations.
  • High-cardinality dimensions can affect reporting, so avoid creating unnecessarily unique values.

Be careful with free-text responses.

GA4 does not allow any personally identifiable information like names, emails or phone numbers and an open-text survey field creates a risk because users can type almost anything into it.

Testing and debugging your survey events

Before launching your survey, you'll want to make sure everything is working as expected.

One option is to use GTM Preview mode and GA4 Debug view to watch events come through in real time.

You can also check the Network tab in Chrome DevTools for collect requests to confirm that the survey event and its parameters were sent.

It’s worth keeping in mind that GA4 events can take up to a period of 24-48 hours to appear in standard reports, so don’t panic if you don’t see the event straight away. 

A few things I'd specifically check as part of your QA:

  • The survey impression event only fires once when the survey is first displayed.
  • Each question view is recorded correctly.
  • Answer events contain the correct question and answer values.
  • Changing an answer doesn't create duplicate responses if you're only interested in the final selection.
  • The completion event is successfully sent when someone submits the survey.
  • Events aren't firing multiple times because of repeated script execution, particularly on single-page applications.
  • Tracking respects the website's consent settings.

Setting up GA4 for reporting

Once you're happy that the events are being collected, you'll need to make the relevant parameters available for analysis.

In GA4, go to Admin > Data display > Custom definitions and create event-scoped custom dimensions for the parameters you want to report on.

For example: 

Dimension nameEvent parameter
Survey namesurvey_name
Question numberquestion_number
Question namequestion_name
Survey answeranswer_value
Experiment IDYour experiment ID parameter
Experiment variationYour variation parameter

Once configured, you can use these dimensions in GA4 Explorations to analyse survey responses.

Agreeing the tracking setup with your analyst

One final recommendation: involve your analyst before you start building.

It's worth agreeing on the survey questions, answer options, event names and parameter values in advance. This ensures that the data being collected is consistent and that the analyst can actually use it in their reporting.

You don't always need another tool

Dedicated survey platforms have their place, particularly when you need more advanced logic, large-scale research or sophisticated response management.

But if you want to run a simple, targeted website survey, your existing A/B testing platform and GA4 may already give you everything you need.

You can build the experience, control who sees it, capture their responses and connect those responses to wider website behaviour, all without introducing another platform into your tech stack.

The most important thing is getting the implementation right from the beginning, so you're collecting meaningful data that you can actually use.

You may also be interested in

The Pros and Cons of AI for CRO Development

It's hard to find a corner of the tech world that generative AI hasn't reached. "Should we use AI here?" has quietly become "where shouldn't we?", and AI code has quickly evolved from a joke into standard industry practice.

Read more about The Pros and Cons of AI for CRO Development