Purchase tracking
Send purchases to PollHero and link them to survey responses.
With purchase tracking, you report every purchase in your shop to PollHero. PollHero links the order to the responses of the same person. You don't need any other integration for this, just the purchase tracking script on your order confirmation page.
What you can do with the purchase data
- Targeting: Show surveys based on revenue, number of purchases, purchased items or coupon code, even right after the purchase. Read more in e-commerce targeting.
- Reporting: The Revenue analysis & extrapolation table and the Discount Code Summary show revenue and average order value per answer. Read more in How we count impressions, responses and rates.
- Post-purchase attribution with KLAR: Responses with order IDs are automatically written to a Google Sheet for KLAR. Read more in KLAR (getklar.com).
Inserting the purchase tracking script
Trigger this script with every purchase, for example via Google Tag Manager on the order confirmation page:
window.PH_API = window.PH_API || [];
window.PH_API.push({
event: "purchase",
transaction_id: "{{dlv - ecommerce.transaction_id}}",
value: {{dlv - ecommerce.value}},
tax: {{dlv - ecommerce.tax}},
currency: "{{dlv - ecommerce.currency}}",
coupon: "{{dlv - ecommerce.coupon}}",
items: {{dlv - ecommerce.items}}
});The example uses the common Google Tag Manager variables from the dataLayer. Your syntax may differ.
| Field | Required | Meaning |
|---|---|---|
transaction_id | yes | Order ID as a string, e.g. "100234" |
value | yes | Order value as a number with a dot as the decimal separator, e.g. 89.90 |
currency | no | Currency, e.g. "EUR". If omitted, PollHero uses EUR. |
tax | no | Tax amount as a number |
coupon | no | Coupon code, e.g. "WELCOME10" |
items | no | List of purchased items (see below) |
If transaction_id is missing or value is empty or 0, PollHero discards the purchase.
Items (items)
For purchased items to be available in e-commerce targeting, each item needs a non-empty sku field. PollHero reads categories from category to category5. The GA4 fields item_category to item_category5 are not evaluated. If you use the standard items from the GA4 dataLayer, add these fields when passing them on.
How PollHero links purchases to responses
The script sends the purchase together with the browser's PollHero user ID. PollHero uses this ID to assign the order to the responses of the same person. You can find out which data is stored in the browser for this in Use of cookies & localStorage.
The same order (same transaction_id) is only sent once within 60 minutes. If someone reloads the order confirmation page, the purchase is not recorded twice.
E-commerce targeting also uses the metrics you send as user attributes (identify). For this, identify and the order must be assigned to the same PollHero user ID.
Retrieving purchase data via the API
The Data Export API returns the respondent ID (respondent.id) with every response. On request, it also returns user attributes such as total_revenue and total_purchases, see Filter by respondent attributes. The API currently does not return the order IDs of individual orders.