Where could I get these parameters from if I using GA4 to log user's purchase events. Answered
Hi ,I am using memberstack + stripe in my saas product. I am using GA4 to log user's purchase events.
1. There is a purchase event in GA4 which needs to be provided with some parameters. But I don't really know where to get the values of these parameters from. just like "transaction_id" , "coupon","currency","value" .
2. When the user fails to pay for some reason, I want to record a separate event named "payment_failed" ,and use the reason for payment failure as the event parameter. I don't know if stripe or memberstack returns the reason for payment failure? How should I get that value?
Could you help me ? Thanks
gtag("event", "purchase", {
transaction_id: "T_12345",
// Sum of (price * quantity) for all items.
value: 72.05,
tax: 3.60,
shipping: 5.99,
currency: "USD",
coupon: "SUMMER_SALE",
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 10.01,
quantity: 3
},
{
item_id: "SKU_12346",
item_name: "Google Grey Women's Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 3.33,
index: 1,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "gray",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 21.01,
promotion_id: "P_12345",
promotion_name: "Summer Sale",
quantity: 2
}]
});
https://developers.google.com/analytics/devguides/collection/ga4/reference/events?sjid=3117304471614638126-NC&client_type=gtag#purchase
purchase
This event signifies when one or more items is purchased by a user.
Parameters
Name | Type | Required | Example value | Description |
---|---|---|---|---|
currency |
string |
Yes* | USD | Currency of the items associated with the event, in 3-letter ISO 4217 format. Value metrics on the view_ event to not contribute to revenue* If you set value then currency is required for revenue metrics to be computed accurately. |
value |
number |
Yes* | 30.03 | The monetary value of the event. * Set value to the sum of (price * quantity) for all items in items . Don't include shipping or tax .* value is typically required for meaningful reporting. If you mark the event as a key event then it's recommended you set value .* currency is required if you set value . |
transaction_ |
string |
Yes | T_12345 | The unique identifier of a transaction. The transaction_ parameter helps you avoid getting duplicate events for a purchase. |
coupon |
string |
No | SUMMER_FUN | The coupon name/code associated with the event. Event-level and item-level coupon parameters are independent. |
shipping |
number |
No | 3.33 | Shipping cost associated with a transaction. |
tax |
number |
No | 1.11 | Tax cost associated with a transaction. |
items |
Array<Item> |
Yes | The items for the event. |
Item parameters
Name | Type | Required | Example value | Description |
---|---|---|---|---|
item_ |
string |
Yes* | SKU_12345 |
The ID of the item. *One of |
item_ |
string |
Yes* | Stan and Friends Tee |
The name of the item. *One of |
affiliation |
string |
No | Google Store | A product affiliation to designate a supplying company or brick and mortar store location. Note: `affiliation` is only available at the item-scope. |
coupon |
string |
No | SUMMER_FUN | The coupon name/code associated with the item. Event-level and item-level coupon parameters are independent. |
discount |
number |
No | 2.22 |
The unit monetary discount value associated with the item.
|
Comments
1 comment
Hello,
Thank you for reaching out.
Memberstack primarily handles user authentication and membership management, while payment processing is typically managed through Stripe. Memberstack does not directly provide transaction details like
transaction_id
,coupon
,currency
, orvalue
for purchases, as these are specific to the payment processor (Stripe).You will need to retrieve these parameters from Stripe, as Memberstack does not provide this information directly.
I hope this helps.
Please sign in to leave a comment.