Set up purchase events for Google tag

You can track all your purchases by setting up purchase events on your website and linking them to Merchant Center. This article explains how to set up purchase events on your website.

Before you begin

To track purchases, ensure that a Google tag is added to your website. If you haven't already added one, you can create a new Google tag and use it on your website. Learn how to Install the Google tag (gtag.js).

How it works

To collect purchase data, you need to track purchase events on your website. You can track these events by defining them on your website.

Below are 2 examples of how a purchase event can be sent from your website.

Example 1: Send purchase event when the page opens

You should place the purchase event on the page of your website where someone makes a purchase. For example, you could add the event on the confirmation page that appears when someone makes a purchase. This tutorial shows you how to add the event to a page where someone clicks a "Purchase" button.

Place the event in a <script> tag at the end of the <body> tag. Placing the event directly in the <script> tag triggers the event when the page loads.

Example 2: Send purchase event when a button is clicked

You can set up the purchase event in a few ways so it triggers when someone clicks a "Purchase" button. One way is to add an ID to the "Purchase" button and then place the event code in an event listener. In the below example, the event is only sent when someone clicks a button with the ID purchase.

Link your purchase events to Merchant Center

You can link purchase events to Merchant Center using key event sources.

Learn how to add key event sources in Merchant Center.

Related links

Was this helpful?

How can we improve it?
1709592425265213560
true
Search Help Center
true
true
true
true
true
71525
Search
Clear search
Close search
Main menu
false
false
false
false