Integrate Shopify discount codes

  • Updated

This integration lets you import your coupon codes from Shopify to use in Optimizely Data Platform (ODP). You can use different coupon codes for various campaigns and segments and assign a unique code based on a customer attribute.

Integrating Shopify discount codes has the following values and benefits:

  • Track which coupon codes were assigned to your customers
  • Re-use the same coupon code in reminder or follow-up touchpoints
  • Give your Support Team insights into which coupon codes were given to customers
  • Give unique codes a static prefix and/or suffix


  • To take advantage of the integration, you must have permission to manage private apps in your Shopify account. (Check for the Manage private apps link at the bottom of the Apps page in Shopify.)
  • You must generate coupon codes prior to launching your campaign.

Configure Shopify discount codes

  1. Log in to your Shopify store and navigate to the Apps page. If you are an admin, you will see Manage private apps. Click on this link.

    Manage private apps link

  2. Click Create a new private app.
    (If this is your first private app in Shopify, you might have to follow the prompts to enable private app development first.)
  3. Enter a memorable name (like "ODP Coupons"), then add as the emergency developer email.
  4. Under Admin API, change Products to No access.
  5. Expand Show inactive Admin API permissions and set Discounts and Price Rules to Read and Write.

    Set Discounts permission

    Set Price Rules permission

  6. Set the Webhook API version to 2020-10.
  7. Click Save. Keep the resulting page open for your API key and password.
  8. In ODP, go to App Directory > Integrations> Shopify Discount Code > Install App. Enter your Shopify store, the API Key, and the password provided from the private app setup, then click Validate Credentials.

Manage your coupon rules

Under Manage Coupon Rules, you can click the drop-down to view all the coupon rules you generated in ODP. The drop-down also shows how many codes remain in each pool. All these rules are showing valid rule_ids that you can use in your campaigns using Liquid.

Manage coupon rules dropdown

Generate coupons

  1. Create a discount code in Shopify to use as a template. (ODP uses the rules of this coupon code.)

    Shopify discount code configuration

  2. In ODP, click Use Discount Code as Template and enter the discount code into Shopify Coupon Code.

    Discount code entry

  3. Under Code Generation, specify a unique rule name (rule_id) to label the coupons, then configure the pool size and any additional parameters. The rule_id must be lowercase, alphanumeric with underscores.

    Code Generation configuration

  4. Click Generate. You can check the progress in the Activity Log.

    Activity Log progress check

Use coupons in a campaign

You can render a unique coupon in your campaign by referring to the ODP rule_id:

{{ app.shopify_discount_codes.generate_coupon(rule_id: 'myRule', email: }}

Code used in campaign

You should a UTM parameter, which (for emails) can be supplied the auto-utms of the campaign by sending the utm_params value, like so:

{{ app.shopify_discount_codes.generate_coupon(rule_id: 'flashsale_2020', email:, utms: utm_params) }}

Remember the number of coupon codes you imported and the number of campaigns in which you use coupon codes. If the number of sends in your campaign exceeds the number of unassigned coupon codes, ODP stops sending after the campaign has used all available unassigned coupon codes. If an automated campaign is configured, and you enabled Maintain pool size, ODP tries to re-send the campaign to customers whose sends were aborted an hour later, after the pool is restored.

Render a coupon multiple times in a single email

You can assign the value to use a coupon multiple times in Variables. Specify your template variable name (such as “coupon_code”), then enter the app call with its parameters:

{{app.shopify_discount_codes.generate_coupon(rule_id: 'myRule', email:, utms: utm_params)}}

You can then use your variable name anywhere later in the template to print the same coupon code in multiple places by typing it in double brackets.


Non-email channels

If a channel uses an identifier other than email address, you should use that channel's identifier for generating coupons. We have added shortcuts for both email and phone.

You can specify these or any other customer identifier manually. We still advise you to include UTM parameters, but non-email channels do not typically have automatic parameters available and need the parameters specified manually.

To use an SMS example, we would use the identifier phone like so:

{{ app.shopify_discount_codes.generate_coupon(
  rule_id: 'myRule',
  identifier_field: 'phone',
  utms: '?utm_source=zaius&utm_medium=sms&utm_campaign=springblast&utm_content=discount')

Or, using the shortcut available for email and phone, like so:

{{ app.shopify_discount_codes.generate_coupon(
  rule_id: 'myRule',
  utms: '?utm_source=zaius&utm_medium=sms&utm_campaign=springblast&utm_content=discount')