# Shopify Event Tracking


This page explains the three methods of tracking Shopify events available in RudderStack's Shopify Source Solution.

## RudderStack Pixel events

- The RudderStack Pixel Shopify app automatically listens to and tracks all the Shopify [Standard Events](https://shopify.dev/docs/api/web-pixels-api/standard-events).
- Because of the strict permissions applicable on the app, you **cannot** load the [RudderStack JavaScript SDK]({{< ref "sources/event-streams/sdks/rudderstack-javascript-sdk/" >}}) on your store. Therefore, all the tracked events are sent to RudderStack via raw HTTP requests.
- You **cannot** make any customizations to the event tracking or track any custom events.
- This method only supports [cloud mode]({{< ref "destinations/rudderstack-connection-modes.md#cloud-mode" >}}) integrations and does not support [device mode]({{< ref "destinations/rudderstack-connection-modes.md#device-mode" >}}) integrations.

### Consent behavior

- Shopify loads the RudderStack Pixel only after the visitor grants analytics consent. RudderStack uses the `[customer_privacy]` configuration in the web pixel extension's `shopify.extension.toml` to ensure that the pixel loads only for visitors who provide the required consent.

  - The pixel requires `analytics = true` within the `[customer_privacy]` configuration to load, while `marketing`, `preferences`, and `sale_of_data` are not required.

- Shopify's consent manager and [Customer Privacy API](https://shopify.dev/docs/api/web-pixels-api/pixel-privacy) control when the pixel can load based on this configuration. RudderStack relies on Shopify's built-in consent behavior and does not require any additional RudderStack configuration for pixel loading.

RudderStack does not use `init.customerPrivacy` or `customerPrivacy.subscribe('visitorConsentCollected')`. That means:

- Once the pixel loads, RudderStack sends all the standard events the pixel subscribes to.
- If a user revokes consent during the same session, for example, via cookie settings, RudderStack still sends events until the next page load, when the pixel may no longer load.

## Custom pixel events

- Similar to the RudderStack Pixel events, the [Shopify Custom Pixel](https://github.com/rudderlabs/shopify-custom-pixel/blob/main/src/index.js) also listens to and triggers events for all the Shopify [Standard Events](https://shopify.dev/docs/api/web-pixels-api/standard-events).
- Because of the relaxed permissions for the custom pixels, you can load the RudderStack JavaScript SDK on your Shopify store. All the events are sent to RudderStack via the JavaScript SDK.
- You can add custom events to the custom pixel code script and edit the tracking script as required.
- This method supports both cloud mode and device mode integrations.

## Webhook events

- These events come from standard webhook topic events that Shopify triggers from their server. RudderStack automatically subscribes you to many of the [webhook topics](https://shopify.dev/docs/api/webhooks?reference=toml#list-of-topics).
- These events are sent from Shopify’s server so they are more reliable. However, they may miss some of the client-side context that events from the Pixels may have, for example, page URLs, campaign information, user information, etc.
- RudderStack generally keeps the webhook topic event name the same but transforms the event properties to align with the [RudderStack Ecommerce Spec]({{< ref "event-spec/ecommerce-events-spec/" >}}).
- This method only supports [cloud mode]({{< ref "destinations/rudderstack-connection-modes.md#cloud-mode" >}}) integrations and does not support [device mode]({{< ref "destinations/rudderstack-connection-modes.md#device-mode" >}}) integrations.

{{< warning >}}
Use [Shopify webhook events]({{< ref "sources/event-streams/cloud-apps/shopify/shopify-source-solution/mappings.md#webhook-events-server-side" >}}) (`Order Created`, `Order Paid`, etc.) as the source of truth for order counts and conversions. 

Frontend web pixel events (like [`checkout_completed`]({{< ref "sources/event-streams/cloud-apps/shopify/shopify-source-solution/mappings.md#pixel-events-client-side" >}})) are not guaranteed to fire because ad blockers can block them or Shopify may not load the pixel until the user grants analytics consent. As a result, web pixel events may undercount orders. Use them for behavioral analysis only, not for total conversions.

See the following references for more details:

- [Pixel is blocked by ad blockers](https://community.shopify.dev/t/pixel-is-blocked-by-ad-blockers/26771)
- [Web pixels requesting consent](https://shopify.dev/docs/apps/build/marketing-analytics/pixels#requesting-consent)
{{< /warning >}}
