Send survey answers to Google Analytics 4

Zenith sends each survey answer to your GA4 property as an event. You set it up once by pasting a custom pixel into your Shopify admin. Zenith never contacts Google and never asks for access to your Google account. Your pixel receives an answer on your Thank you page only when the customer has allowed analytics, and sends it with your own GA4 tag.

What gets sent

Each answered question sends one zenith_survey_response event with these parameters:

ParameterExample
zenith_question_idcmtrlorb50002unq4lfgc9tat
zenith_questionHow did you hear about us?
zenith_answerInstagram
zenith_order_id7677568713013

Values longer than 100 characters are shortened to 100. An answer with several choices is sent as one comma separated value, for example Instagram, A friend.

Typed text stays out of Google Analytics

Free-text answers and comments are never sent to GA4, by design. Google Analytics does not allow anything it could use to identify a person, and a text box is where a customer is most likely to type an email address or a phone number. Leaving all typed text out means no survey answer can put your property in breach of that policy. That covers open-ended questions and whatever a customer types after choosing Other, which reaches GA4 as the answer Other. Every typed answer is still in Zenith and in your CSV export. Skipped questions are not sent either.

Before you start

  • A GA4 property with a web data stream, and its Measurement ID, which starts with G-. Find it in Google Analytics under Admin > Data streams.
  • Zenith's survey block on your Thank you page.

Add the pixel

  1. Open Customer events

    In your Shopify admin, go to Settings > Customer events.

  2. Add a custom pixel

    Click Add custom pixel, name it Zenith to GA4, and click Add pixel.

  3. Set the privacy permission

    Under Customer privacy, set Permission to Required and select Analytics. Set Data sale the way you set it for your other Google Analytics tags; that choice is yours to make for your store.

  4. Paste the code

    Replace everything in the code box with the snippet below, and change G-XXXXXXXXXX to your own Measurement ID.

  5. Save and connect

    Click Save, then Connect pixel.

// Zenith survey answers to Google Analytics 4
const MEASUREMENT_ID = "G-XXXXXXXXXX"; // your GA4 Measurement ID

const script = document.createElement("script");
script.src = "https://www.googletagmanager.com/gtag/js?id=" + MEASUREMENT_ID;
script.async = true;
document.head.appendChild(script);

window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());
// Your existing Google setup records page views. This pixel only sends survey answers.
gtag("config", MEASUREMENT_ID, { send_page_view: false });

analytics.subscribe("zenith:survey_response", (event) => {
  gtag("event", "zenith_survey_response", {
    ...event.customData,
    // Records your Thank you page as the page, instead of the pixel's own sandbox address.
    page_location: event.context.document.location.href,
  });
});

Register the parameters in GA4

GA4 only lets you filter and break down reports by a parameter after you register it as a custom dimension. Do this once for each parameter you want to report on; most stores want zenith_question and zenith_answer.

  1. In Google Analytics, open Admin and, under Data display, click Custom definitions.
  2. On the Custom dimensions tab, click Create custom dimensions.
  3. Enter a Dimension name, set Scope to Event, enter the parameter name, such as zenith_answer, as the Event parameter, and click Save.

Google says a new custom dimension can be added to reports 24 to 48 hours after it is created and data has been sent.

What to expect

  • Thank you page only. Set this up for answers given on the Thank you page. The Order status page runs pixels only when your customer accounts use your own domain, so answers given there may not arrive.
  • This counts answers. It is not attribution. Use it to see how many customers gave each answer alongside the rest of your GA4 data. Do not read a survey event's source or medium as the channel that brought that customer in: the event is sent from your Thank you page, so GA4 may credit it to a different session or to Direct. Zenith's own dashboard is where answers are tied to order revenue.
  • Consent. Zenith passes an answer to your pixel only when the customer has allowed analytics. If they have declined, or have not chosen yet, the answer stays in Zenith and goes no further. The pixel's Customer privacy setting checks consent again.
  • Your other tags are unchanged. If you already send events to the same property from another tool, this pixel does not touch them. It only adds zenith_survey_response.

Check it works

  1. Open the Realtime report in Google Analytics.
  2. Place a test order and answer a multiple choice question on the Thank you page, with analytics cookies accepted.
  3. Look for a zenith_survey_response event.

If nothing arrives, check that the pixel shows as connected under Settings > Customer events and that the Measurement ID is correct.

Install Zenith from the Shopify App Store