How to filter Shopify transactions being tracked?

In this article, we will explain the Shopify Purchase Filtering functionality, its configuration, and common use cases: filtering by SKU, filtering by subscription status, and filtering by product type.

Shopify Purchase Filtering: A Comprehensive Guide

Shopify Purchase Filtering enables the advanced filtering of events based on specified properties and values. This functionality ensures precise targeting and processing of events, such as purchases or conversions, based on predefined conditions.

Configuring Shopify Purchase Filtering

You need to implement the Convert Shopify Manual Integration and then edit the Customer Event Pixel code to configure the filtering.

The Shopify Purchase Filtering functionality is highly configurable, enabling you to specify the properties and values to be checked in incoming events. The configuration is defined in the filterCriteria object as follows:

const filterCriteria = {
enabled: true, // Enable or disable criteria checking
checkExistence: ['property1', 'property2'], // List of properties that must exist
matchValue: {
'property1': 'value1', // Exact string values to match
'property2': 'value2'
},
checkValue: true // Enable or disable value matching
};

Configuration Options

  • enabled: A Boolean flag to enable or disable Shopify Purchase Filtering.
  • checkExistence: An array of property names that must exist in the event for it to pass the criteria check.
  • matchValue: An object defining specific property-value pairs for exact matching. Only tested if checkValue is set to true.
  • checkValue: A Boolean flag to enable or disable value matching.

Helper Functions

To aid in Shopify Purchase Filtering, the following helper functions are used:

  • isValidJSON(): Checks whether a given data string is valid JSON.
  • debugLog(): Logs debug messages when the DEBUG flag is true.
  • findProperty(): Recursively searches for a property name within an object.
  • checkCriteria(): Checks whether an event meets the criteria specified in the filterCriteria configuration.

Use Cases

Filtering by SKU

Filtering by SKU ensures that only events for specific products are processed. This is useful for targeting specific product campaigns or experiments.

const filterCriteria = {
enabled: true,
checkExistence: ['sku'], // Only need to mention the property name
matchValue: {
'sku': '23026961-pink-united-states-l-diameter-7-5cm'
},
checkValue: true // Enable exact value matching for specific SKU
};

Filtering by Subscription

Filtering by subscription ensures that subscription-based transactions are processed differently from non-subscription transactions.

const filterCriteria = {
enabled: true,
checkExistence: ['selling_plan_allocation'], // Only need to mention the property name
checkValue: false // Disable value matching, only check existence
};

You can find an example of Subscription tracking here.



Filtering by Product Type

Filtering by product type allows you to process events based on the type of product involved. This is useful for product-type-specific promotions or analytics.

const filterCriteria = {
enabled: true,
checkExistence: ['product_type'], // Only need to mention the property name
matchValue: {
'product_type': 'Apparel'
},
checkValue: true // Enable exact value matching for specific product type
};