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.

TriggerDescriptionOperators
Current URLMatch the page the customer is on. You can add multiple urls herecontains, is, is not, starts with, ends with
Time Spent on PageFire after the customer has been on the page for X secondsgreater than, equal to
Number of VisitsTarget by how many times the customer has visitedgreater than, less than, equal to
Exit IntentFire when the customer shows signs of leaving
Traffic SourceMatch the referrer page urlequal to, not equal to, contains
CustomMatch 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.

TriggerDescriptionOperatorsRequires in DG_CAMPAIGNS_VARS
Total Value in CartCart value threshold (calculated in store currency)greater than, less than, equal toamountAddedToCart
Number of Items in CartNumber of items in the cartgreater than, less than, equal tonoOfItemsInCart
Product Tags in CartTags present on products currently in the customer's cartequal to, not equal to, containsproductTagsInCart
Currently Visited ProductTags present on the product page being viewedequal to, not equal to, containscurrentProductTags
Viewed Product Tag CountNumber of unique products viewed with any of the selected tagsgreater than, less than, equal tocurrentProductId, currentProductTags
Number of OrdersCustomer's lifetime order countgreater than, less than, equal tonumberOfOrders
Total SpentCustomer's lifetime spendgreater than, less than, equal tototalSpent
Customer TagsSegmentation based on tags assigned to the customercontainscustomerTags
Customer CountryThe customer's locationequal to, not equal to, containscustomerCountry
Purchased Product TagsTags present on the customer's historical ordersequal to, not equal to, containspurchasedProductTags
Product Out of StockFire when the product page being viewed has no variants available to purchaseequal to, not equal toisProductOutOfStock

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

PropertyTypeNotes
currentProductTagsstring[]Tags on the product currently being viewed. [] on non-product pages.
currentProductIdstring | nullStable id for the product currently being viewed. null on non-product pages.
productTagsInCartstring[]De-duplicated tags across all products currently in the cart.
purchasedProductTagsstring[]De-duplicated tags across every product the customer has ever purchased. [] for guests.
amountAddedToCartnumberCart total in the store's currency (dollars/pounds — not cents).
customerTagsstring[]Tags on the customer record. [] for guests.
customerCountrystringISO 3166-1 alpha-2 country code, e.g. "GB", "US". Never empty.
numberOfOrdersnumberLifetime order count. 0 for guests.
totalSpentnumberLifetime spend in the store's currency. 0 for guests.
noOfItemsInCartnumberTotal quantity of items in the cart.
isProductOutOfStockbooleanWhether 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 → currentProductTags is non-empty and currentProductId is set.
  • After viewing products with matching tags → DG_CHAT_CAMPAIGN_PRODUCT_TAG_VIEWS stores arrays of unique product IDs by tag. The viewed product tag count condition derives its count from those stored IDs.
  • With items in cart → productTagsInCart and noOfItemsInCart reflect them.
  • As a logged-in returning customer → purchasedProductTags, numberOfOrders, and totalSpent are populated.
  • customerCountry is 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.

AttributeWrite onValue
_dg_campaign_idCampaign impressionComma-separated list of campaign IDs seen in the session, e.g. "id1, id2"
_dg_engagement_timestamp_campaign_<campaignId>Campaign engagementISO 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:

  • currentProductIdproduct.id
  • currentProductTagsproduct.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:

  • noOfItemsInCartcart.totalQuantity
  • amountAddedToCartNumber(cart.cost.totalAmount.amount) (already in the store currency — no division)
  • productTagsInCart ← de-duplicated product.tags across 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:

  • customerTagscustomer.tags
  • numberOfOrdersNumber(customer.numberOfOrders)
  • totalSpentNumber(customer.amountSpent.amount)
  • customerCountrycustomer.defaultAddress?.countryCodeV2 (or the @inContext(country:) directive context)
  • purchasedProductTags ← flatten and de-dupe product.tags across 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.


Did this page help you?