Made in Builder

×

Developers

Product

Use Cases

Pricing

Developers

Resources

Company

Get StartedLogin

Product

Pricing

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

Setting up E-commerce Targeting

You can target content based on user interactions with your e-commerce platform's resources—such as products or collections—by using e-commerce plugins.

In order for e-commerce resource targeting to work, your app must pass the appropriate targeting attributes to Builder. For example, if you target an announcement bar to display when a user adds a certain item to their cart, your app must pass the product's ID whenever requesting the announcement bar's content.

Passing e-commerce targeting attributes

You can pass targeting attributes either by using the JavaScript (JS) SDK or with query string parameters when requesting content using the content/GraphQL APIs.

The e-commerce custom type that you use for your targeting condition determines which targeting attribute you use. For example, when using a request object type like ShopifyProduct—displayed in the custom types list as Shopify Product when creating a new targeting condition—you must pass the Shopify ID for your product to the product attribute.

You can implement the above using the following code when using the SDK:

You can alternatively use setUserAttributes to set the targeting attributes once across multiple content requests:

Finally, when requesting content with the content or GraphQL APIs, you can pass the targeting attributes using query strings:

If product.id matches the ID of the product selected for your targeting condition, then your content will be rendered.

Targeting content with e-commerce targeting conditions

After setting up your codebase to pass targeting attributes to Builder, you can target content using e-commerce targeting conditions. For example, you can show users an announcement bar when a certain product is in the cart.

To learn how to set up targeting, refer to Targeting with e-commerce plugins.

Next steps

For more information on how to use e-commerce plugins, check out the following articles:

Was this article helpful?