# GA4 Shopify Pixel

Connect your GA4 account to your Shopify Checkout Extension to collect Zigpoll survey data in your GA4 analytics dashboard.

{% hint style="info" %}
This guide is specific to the Shopify Checkout Extension. For the general Google Analytics integration, see [Google Analytics](/integrations/google-analytics.md).
{% endhint %}

#### Step #1: Create a Custom Pixel in Shopify

1. Go to your **Shopify Dashboard → Settings → Customer Events**.
2. Click **Add custom pixel**.
3. Paste the following JavaScript code into the code block.

{% hint style="warning" %}
Replace **G-XXXX** with your GA4 Measurement ID. You can find your GA4 ID in GA4 by going to: Property settings → Data collection and modification → Data Streams → Click applicable stream → copy "Measurement ID".
{% endhint %}

```javascript
/* Zigpoll GA Integration Pixel */
var f = document.getElementsByTagName('script')[0];
var j = document.createElement('script');
j.async = true;
j.src='https://www.googletagmanager.com/gtag/js?id=G-XXXX';
f.parentNode.insertBefore(j, f);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXX');

analytics.subscribe("zigpoll-event", (event) => {
  const { customData } = event;

  gtag("event", customData.action, {
    event_category: customData.category,
    event_label: customData.label,
    order_id: customData.order_id,
    zigpoll_response: customData.response,
    zigpoll_question: customData.question
  });
});
```

{% hint style="info" %}
Shopify only allows web pixels on the **Thank You** page as of now. We hope they will allow web pixels on the Order Status page in the future and will update this page accordingly.
{% endhint %}

#### Step #2: Set Up Custom Dimensions in GA4

1. Go to your **GA4 Dashboard**.
2. Click **Admin → Custom Definitions**.
3. Click **Add custom dimension** and enter the following:

| Dimension Name   | Event Parameter    |
| ---------------- | ------------------ |
| Zigpoll Response | `zigpoll_response` |
| Zigpoll Question | `zigpoll_question` |

Once both dimensions are created, Zigpoll survey response data will begin appearing in your GA4 reports.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zigpoll.com/integrations/ga4-shopify-pixel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
