Campaigns for Non-Shopify Stores
Campaigns enable you to reach customers with timely, targeted messages exactly when it matters most. Reduce cart abandonment, increase conversions, and unlock upsell opportunities - all powered by real-time triggers and smart segmentation.
This guide covers non-Shopify platforms — Magento, WooCommerce, BigCommerce, custom storefronts, and headless Shopify setups. Browser-based conditions (URL, visits, exit intent, traffic source) and Custom Conditions work out of the box. Cart, product, customer, and order conditions are also available if you optionally provide the data DigitalGenius needs to evaluate them.
On a standard Shopify Online Store theme? Use Campaigns for Shopify Stores instead - the DigitalGenius Shopify app handles shopper signals, cart attribution, and discount codes automatically.
See also: Campaign Examples.
Getting Started
Prerequisites
- Ensure the Campaigns feature is enabled on your Dashboard account (your CSM can help with this).
First steps
Creating, editing, and publishing campaigns uses the same Dashboard flow as Shopify. Log in to the DigitalGenius Dashboard, open Chat Widget → All Campaigns, and click New Campaign.
Each campaign is made up of:
- Conditions — Rules that determine when a campaign fires. See Conditions below.
- Message — The message shown to the customer.
- Display — Device targeting and optional delay.
- Content — Optional products, discount codes, or videos.
- Publishing & Schedule — Publish now, save as draft, or schedule.
- Link a Campaign to a Widget — Assign the campaign in the Widget Builder.
For the full builder walkthrough (message formatting, display options, content, publishing, linking, and analytics), see Campaigns for Shopify Stores.
Conditions
Campaigns are triggered by one or more conditions. Conditions can be combined using AND / OR logic.
Conditions available out of the box
These conditions use browser signals only. No extra storefront integration is required.
| Trigger | Description | Operators |
|---|---|---|
| Current URL | Match the page the customer is on. You can add multiple urls here | contains, is, is not, starts with, ends with |
| Time Spent on Page | Fire after the customer has been on the page for X seconds | greater than, equal to |
| Number of Visits | Target by how many times the customer has visited | greater than, less than, equal to |
| Exit Intent | Fire when the customer shows signs of leaving | — |
| Traffic Source | Match the referrer page url | equal to, not equal to, contains |
| Custom | Match data passed from your own site, backend, CDP, loyalty provider, subscription platform, or CRM. See Custom Conditions. | Depends on value type |
Exit intent — desktop: detected when the cursor moves to the top of the viewport or leaves the browser window.
Exit intent — mobile: detected by a fast upward scroll at the top of the page.
Conditions that require advanced configuration
The following conditions are available on non-Shopify storefronts, but only if you populate window.DG_CAMPAIGNS_VARS with the matching data. See Advanced configuration below.
| Trigger | Description | Operators | Requires in DG_CAMPAIGNS_VARS |
|---|---|---|---|
| Total Value in Cart | Cart value threshold (calculated in store currency) | greater than, less than, equal to | amountAddedToCart |
| Number of Items in Cart | Number of items in the cart | greater than, less than, equal to | noOfItemsInCart |
| Product Tags in Cart | Tags present on products currently in the customer's cart | equal to, not equal to, contains | productTagsInCart |
| Currently Visited Product | Tags present on the product page being viewed | equal to, not equal to, contains | currentProductTags |
| Viewed Product Tag Count | Number of unique products viewed with any of the selected tags | greater than, less than, equal to | currentProductId, currentProductTags |
| Number of Orders | Customer's lifetime order count | greater than, less than, equal to | numberOfOrders |
| Total Spent | Customer's lifetime spend | greater than, less than, equal to | totalSpent |
| Customer Tags | Segmentation based on tags assigned to the customer | contains | customerTags |
| Customer Country | The customer's location | equal to, not equal to, contains | customerCountry |
| Purchased Product Tags | Tags present on the customer's historical orders | equal to, not equal to, contains | purchasedProductTags |
| Product Out of Stock | Fire when the product page being viewed has no variants available to purchase | equal to, not equal to | isProductOutOfStock |
For generated campaign configuration, Viewed Product Tag Count stores the selected tags under value.tags and the numeric threshold under value.count.
You only need to populate the fields for conditions you intend to use. Unused fields can be omitted, or set to safe defaults such as [], 0, or null as appropriate.
Advanced configuration
Advanced configuration is optional. Skip it if you only need browser-based or custom conditions.
Use the sections below if you want to:
- Target campaigns with cart, product, customer, or order conditions
- Attribute conversions via cart attributes
- Apply discount codes from a campaign button
Populate window.DG_CAMPAIGNS_VARS (optional)
If you want to use cart, product, customer, or order conditions, set window.DG_CAMPAIGNS_VARS in <head> (or early in <body>) on every storefront page before the campaign script runs. Only include the fields required by the conditions you plan to use. Missing fields will cause campaigns that depend on those signals to misfire.
Schema
| Property | Type | Notes |
|---|---|---|
currentProductTags | string[] | Tags on the product currently being viewed. [] on non-product pages. |
currentProductId | string | null | Stable id for the product currently being viewed. null on non-product pages. |
productTagsInCart | string[] | De-duplicated tags across all products currently in the cart. |
purchasedProductTags | string[] | De-duplicated tags across every product the customer has ever purchased. [] for guests. |
amountAddedToCart | number | Cart total in the store's currency (dollars/pounds — not cents). |
customerTags | string[] | Tags on the customer record. [] for guests. |
customerCountry | string | ISO 3166-1 alpha-2 country code, e.g. "GB", "US". Never empty. |
numberOfOrders | number | Lifetime order count. 0 for guests. |
totalSpent | number | Lifetime spend in the store's currency. 0 for guests. |
noOfItemsInCart | number | Total quantity of items in the cart. |
isProductOutOfStock | boolean | Whether the current product is out of stock. |
Populate each field from your commerce platform's API or session data. For guests, fall back to [] or 0 as appropriate.
Example
window.DG_CAMPAIGNS_VARS = {
currentProductId: 'product-123',
currentProductTags: ['sale', 'summer'],
productTagsInCart: ['sale'],
purchasedProductTags: [],
amountAddedToCart: 49.99,
customerTags: [],
customerCountry: 'US',
numberOfOrders: 0,
totalSpent: 0,
noOfItemsInCart: 2,
isProductOutOfStock: false,
};Validating
After deploying, open any storefront page and run:
console.log(window.DG_CAMPAIGNS_VARS);Quick checks:
- On a product page →
currentProductTagsis non-empty andcurrentProductIdis set. - After viewing products with matching tags →
DG_CHAT_CAMPAIGN_PRODUCT_TAG_VIEWSstores arrays of unique product IDs by tag. The viewed product tag count condition derives its count from those stored IDs. - With items in cart →
productTagsInCartandnoOfItemsInCartreflect them. - As a logged-in returning customer →
purchasedProductTags,numberOfOrders, andtotalSpentare populated. customerCountryis always a 2-letter code.
Cart attribution (optional)
Optional. Use this if you want campaign conversion analytics via cart attributes.
On non-Shopify platforms, write attribution yourself using the campaignAnalytics callback.
| Attribute | Write on | Value |
|---|---|---|
_dg_campaign_id | Campaign impression | Comma-separated list of campaign IDs seen in the session, e.g. "id1, id2" |
_dg_engagement_timestamp_campaign_<campaignId> | Campaign engagement | ISO timestamp of the engagement |
window.DG_CHAT_WIDGET_CONFIG = {
// ...
callbacks: {
campaignAnalytics: async (type, campaign) => {
switch (type) {
case 'impression': {
await updateCartAttributes(prev => ({
_dg_campaign_id: prev._dg_campaign_id
? `${prev._dg_campaign_id}, ${campaign.id}`
: campaign.id,
}));
break;
}
case 'engagement': {
await updateCartAttributes({
[`_dg_engagement_timestamp_campaign_${campaign.id}`]:
new Date().toISOString(),
});
break;
}
}
},
},
};Applying discount codes (optional)
Optional. Use this only if your campaigns include discount code buttons.
Wire up discount application with the onCampaignDiscountCodeClick callback. It receives the discount code string and must return a Promise.
window.DG_CHAT_WIDGET_CONFIG = {
// ...
callbacks: {
onCampaignDiscountCodeClick: async (discountCode) => {
await fetch('/api/apply-discount', {
method: 'POST',
body: JSON.stringify({ code: discountCode }),
});
},
},
};Headless Shopify: Storefront API examples (optional)
If you are on a headless Shopify storefront (Hydrogen, custom front ends, or anything where Liquid and /cart/update.js are unavailable) and want cart, product, or customer conditions, populate window.DG_CAMPAIGNS_VARS from the Storefront API. For guests, fall back to [] / 0.
Current product
query GetProduct($handle: String!) {
product(handle: $handle) {
id
tags
}
}Maps to:
currentProductId←product.idcurrentProductTags←product.tags
Cart
query GetCart($cartId: ID!) {
cart(id: $cartId) {
totalQuantity
cost { totalAmount { amount currencyCode } }
lines(first: 100) {
edges {
node {
merchandise {
... on ProductVariant {
product { tags }
}
}
}
}
}
}
}Maps to:
noOfItemsInCart←cart.totalQuantityamountAddedToCart←Number(cart.cost.totalAmount.amount)(already in the store currency — no division)productTagsInCart← de-duplicatedproduct.tagsacross all lines
Customer (requires a customer access token)
query GetCustomer($token: String!) {
customer(customerAccessToken: $token) {
tags
numberOfOrders
amountSpent { amount currencyCode }
defaultAddress { countryCodeV2 }
orders(first: 250) {
edges {
node {
lineItems(first: 100) {
edges {
node {
variant { product { tags } }
}
}
}
}
}
}
}
}Maps to:
customerTags←customer.tagsnumberOfOrders←Number(customer.numberOfOrders)totalSpent←Number(customer.amountSpent.amount)customerCountry←customer.defaultAddress?.countryCodeV2(or the@inContext(country:)directive context)purchasedProductTags← flatten and de-dupeproduct.tagsacross all orders
For optional cart attribution on headless Shopify, use a cartAttributesUpdate Storefront API mutation (or your own cart layer) inside the campaignAnalytics callback. Discount codes can be applied via onCampaignDiscountCodeClick when needed.
Updated 6 days ago
