Purchase Event Tracking on E-Commerce Sites: A Complete Setup Guide

The most critical way to measure your ad performance and net revenue on an e-commerce site is to track purchases accurately.

Purchase Event Tracking on E-Commerce Sites: A Complete Setup Guide

The most critical way to measure your ad performance and net revenue on an e-commerce site is to track purchases accurately. Purchase event tracking directly determines how well your ad budget performs.

What is a purchase event and why does it matter?

A purchase event is the digital interaction that shows a user has successfully completed the payment step on your site and placed an order.

  • ROAS measurement: It lets you see the return on your ad spend (ROAS) down to the last penny.

  • AI optimization: Ad platforms use this data to steer your budget toward the audiences that actually buy from your site.

  • Accurate analysis: It shows clearly which product sold how much, and from which source (Google, Meta, TikTok).

What are the purchase event parameters?

Sending the purchase conversion to the platforms is not enough on its own. You also need to send the details of the sale to the ad panels and to GA4. Some of the important purchase event parameters:

  • Transaction ID (order number): The unique code of each order (e.g. TS1234). It prevents double counting.

  • Value (total amount): The net monetary value of the order (e.g. 1450.00).

  • Currency: The currency the sale was made in (e.g. TRY, USD).

  • Items (product details): The data array containing the ID, name, category, price and quantity of the purchased products.

Setting up the purchase event with Google Tag Manager

Before you can set up the purchase event with Google Tag Manager, your development team needs to have added the purchase dataLayer code to the order success (Thank You) page. Here is a sample purchase code:

<script>

window.dataLayer = window.dataLayer || [];

window.dataLayer.push({

'event': 'purchase',

'ecommerce': {

'transaction_id': 'TS-12345',

'value': 450.00,

'currency': 'TRY',

'coupon': 'ANATOMI', // Valid discount coupon

'items': [

{

'item_id': 'TS-BASIC-BLACK',

'item_name': 'Basic Tshirt - Black',

'item_category': 'Clothing',

'price': 450.00,

'quantity': 1

}

]

}

});

</script>

Step 1: Creating the data layer (dataLayer) variables

Open your GTM panel. Follow the Variables > New path. To pull information such as the price and order number from the data layer, choose the Data Layer Variable type:

  • For the total amount: ecommerce.value

  • For the currency: ecommerce.currency

  • For the order number: ecommerce.transaction_id

  • For the products: ecommerce.items

Step 2: How do you create the purchase event trigger?

  • Triggers > New — click this option.

  • As the trigger type, choose Custom Event from the list.

  • In the Event name field, type the exact event name your software sends

  • Name the trigger Custom Event - Purchase and save it.

Step 3: Configuring the GA4 event tag

  • Tags > New — create a new tag here.

  • Google Analytics > GA4 Event — select this tag type.

  • In the Event Name field, type purchase in lowercase.

  • Event Parameters — map the variables you created above in this field:

  • transaction_id -> {{dlv - transaction_id}}

  • value -> {{dlv - value}}

  • currency -> {{dlv - currency}}

  • items -> {{dlv - items}}

  • Select the purchase trigger you created in step 2 as the trigger and save the tag.

Testing and verifying the setup

Once the setup is complete, click the Preview button in the top right corner of GTM. Run a test purchase on your site.

You should see the purchase event on the left side of the GTM Debug screen. When you click that event, make sure the GA4 tag you created appears under "Tags Fired" and that the parameters carry the correct price. Also, from the DebugView screen in your GA4 panel, confirm that the data is coming through live.

Common mistakes and how to fix them

Orders counted twice: If the user refreshes the order success page, the event can fire again. The successful purchase (Thank You) screen should be set up so the user can only view it once.

Discounts not reflected in the dataLayer at the checkout steps: For example, with a campaign like 10% off in the cart, the product price needs to be pushed again according to the applicable discount rate once the user reaches the payment steps.Decimal separator error: Sending the price with a comma, such as 1.250,00, causes it to appear incorrectly on the platforms. On the development side, the value parameter should be sent as a float separated by a period (1250.00).

Frequently asked questions

1. What is a purchase event and why does it matter? It is the e-commerce measurement event that tracks successful purchases made through your site. It is the most important data you have for understanding how much revenue your ad budget brings in (ROAS) and for optimizing it.

2. What are the purchase event parameters? The essential parameters for a purchase event to work properly are the unique order number (transaction_id), the total order amount (value), the currency (currency) and the list of purchased products (items).

3. How do you create a purchase event trigger? In Google Tag Manager you create a "Custom Event" trigger and enter, in the event name field, the purchase name that your website's software pushes to the DataLayer the moment an order is completed.