> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/advertisers/conversion-tracking/tracking-manuals/shopify-tracking.md).

# How to track conversions with Shopify

*This guide is for Shopify only. If you want to know the generic steps for conversion tracking, please check the* [*Advertisers section*](/advertisers/conversion-tracking/conversion-tracking.md)*.*

ExoClick gives you access to global traffic sources, targeting features, big data and statistical analytical tools to filter results and optimise your campaigns. This manual explains how to track conversions from your Shopify store on the ExoClick network.

In this documentation, we will provide two examples of event tracking:

* **checkout\_completed**
* **product\_added\_to\_cart**

Before we proceed with the examples, please make sure to have a [**conversion goal**](/advertisers/conversion-tracking/conversion-tracking.md#creating-a-conversion-goal) created in your account.

## Checkout Completed Event

If you want to track purchases on your Shopify store using ExoClick Pixel tracking, you can utilize events like `checkout_completed`. This event logs when a visitor completes a purchase and is triggered once for each checkout. It's important to note that in this example, the value of the conversion goal is dynamic.

To add the `checkout_completed` event to your Shopify store, follow these steps:

{% stepper %}
{% step %}
Go to **Settings** in your Shopify admin panel.
{% endstep %}

{% step %}
Select **Customer events**.
{% endstep %}

{% step %}
Click on **Add Custom Pixel**.

<figure><img src="/files/GbZ8MQoMQkv3IQGQENUZ" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Set **Permission to Marketing** required to comply with the Cookies Policy.

<figure><img src="/files/vogOytMirCZmcWeSp1Yy" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Add the following code:

```javascript
analytics.subscribe('checkout_completed', (event) => {
  const el = document.createElement('script');
  el.setAttribute('src', 'https://a.magsrv.com/tag_gen.js');
  el.setAttribute('data-goal', 'XXXXX');
  const cost = event.data.checkout.subtotalPrice?.amount || event.data.checkout.totalPrice?.amount;
  el.setAttribute('data-value', cost);

  document.body.appendChild(el);
});
```

{% endstep %}

{% step %}
Make sure to replace `'XXXXX'` with your own goal ID.
{% endstep %}

{% step %}
Finally, press the **Connect** button.

<figure><img src="/files/tlj7SoXfDKcZnGjk7Pd5" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

Once connected, make a test purchase using Shopify's test payment feature to confirm everything is set up correctly.

After a successful checkout, you should see conversions along with the dynamic value recorded in the revenue section of your ExoClick admin dashboard.

{% hint style="info" %}
**Note:** It may take a couple of minutes for the conversion to appear in your ExoClick admin panel.
{% endhint %}

<figure><img src="/files/VjuJl3oTAEyCNc6NX79y" alt=""><figcaption></figcaption></figure>

## Product Added to Cart Event

The `product_added_to_cart` event tracks when a customer adds an item to their shopping cart. It is important to note that, in this example, there is no assigned value for the conversion goal.

To set it up, follow the same steps as outlined previously for the `checkout_completed` event. However, please note that the code will differ this time.

* Add the following code:

```javascript
analytics.subscribe('product_added_to_cart', (event) => {
  const el = document.createElement('script');
  el.setAttribute('src', 'https://a.magsrv.com/tag_gen.js');
  el.setAttribute('data-goal', 'XXXXXX');

  document.body.appendChild(el);
});
```

* Make sure to replace `'XXXXX'` with your own goal ID.
* Finally, press the **Connect** button.

Once connected, test the setup by adding a product to the cart. If everything is configured correctly, you will see the conversion reflected in your ExoClick admin panel.

{% hint style="info" %}
**Note:** It may take a couple of minutes for the conversion to appear in your ExoClick admin panel.
{% endhint %}

<figure><img src="/files/xZkxsA0EB8NOg4OSvy11" alt=""><figcaption></figcaption></figure>

## Additional Event Setup

If you'd like to set up other types of events, please refer to the Shopify manual [Shopify Standard Events Documentation](https://shopify.dev/docs/api/web-pixels-api/standard-events).

{% hint style="warning" %}
**Note:** These events are custom-built. If you would like to add more events, kindly be aware that this will require your own development effort.
{% endhint %}

If you want to find additional information regarding Shopify pixels, please refer to this page: [Shopify Pixels Documentation](https://help.shopify.com/en/manual/promoting-marketing/pixels)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/advertisers/conversion-tracking/tracking-manuals/shopify-tracking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
