Skip to main content

Generate bulk coupon codes in Adobe Commerce and Magento Open Source

Create unique, single-use coupon codes for a whole list or segment in one job, ready to use in your email and SMS campaigns.

Written by Gareth Burroughes

Bulk coupons let you generate unique coupon codes in Magento Open Source and Adobe Commerce for every contact in a Marketing list or segment. Each contact gets their own code, saved to a contact data field in Marketing, so you can add it to any campaign with personalisation.

Because the codes are created before you send, bulk coupons suit promotional and broadcast campaigns where you know the audience up front, including very large lists and segments. For automations and triggered campaigns, where contacts join over time, use dynamic content coupon codes instead.


Before you start

  • You need Dotdigital for Magento 2 version 4.37.0 or later.

  • The Magento website you generate coupons for must be connected to your Marketing account. The lists, segments, and data fields you can choose come from that account.

  • Coupon codes are matched to contacts by email address. Contacts without an email address, such as SMS-only contacts, don't get a code.

  • Unsubscribed and suppressed contacts aren't included in lists and segments, so they don't get a code.


1. Set up a cart price rule

Every bulk coupon job uses a cart price rule. The rule controls the discount, who can use it, and when it's valid.

  1. In Magento, go to Marketing > Cart Price Rules, then select Add New Rule, or select an existing rule to edit it.

  2. Set up the rule's name, websites, customer groups, conditions, and actions for your discount.

  3. Expand the Coupon drop-down menu, then choose Specific Coupon.

  4. Select the Use Auto Generation checkbox.

  5. For Uses per Coupon and Uses per Customer, enter 1 or whatever usage limits you want to set.

  6. Select Save.

Only rules with Specific Coupon and Use Auto Generation set appear when you create a coupon job.


2. Create a coupon job

  1. In Magento, go to Marketing > Dotdigital Bulk Coupons, then select Add New Job.

  2. Expand the Scope drop-down menu, then choose the website you want to generate coupons for. The scope controls which cart price rules are available and which Marketing account the coupons are sent to.

  3. Expand the Cart Price Rule drop-down menu, then choose the rule you set up in the previous section.

  4. Expand the Code Format drop-down menu, then choose Alphanumeric, Alphabetical, or Numeric.

  5. Optionally, for Code Prefix and Code Suffix, enter text to add to the start or end of every code.

  6. For Code Length, enter the number of random characters in each code. This doesn't include the prefix, suffix, or dashes. The default is 12.

  7. For Dash Every X Characters, enter how often to add a dash between the random characters. Enter 0 for no dashes.

  8. For Audience Preview, select List or Segment, then search for and choose the list or segment you want to send codes to. The total number of contacts in the list or segment shows next to its name.

  9. For Dotdigital Data Field, search for and choose the data field to save the codes in, or enter a new name and press Enter to create a new data field. Only text data fields appear. Default data fields and data fields already mapped to Magento data aren't shown.

  10. Optionally, for Expires At, choose the date the codes expire. Leave it blank to generate codes with no expiry date.

For example, a prefix of SUMMER, a suffix of 2026, a code length of 12, and a dash every four characters produces codes like SUMMERA7K2-9QXM-4TPB2026.

Codes are also limited by the dates on the cart price rule. If the rule has an end date, codes stop working on that date, even if you set a later expiry.

Use a separate data field for each promotion

Running a new job with the same data field replaces the codes already saved there. If a campaign is still using those codes, choose or create a different data field for the new job.


3. Review and generate your coupons

Generated codes can't be undone

When you select Generate, the job starts straight away and saves a code to the data field for every contact in your audience. You can't undo this. To replace the codes, run a new job with the same data field.

  1. Select Review.

  2. Under Confirm Coupon Generation, check the summary of your job. The summary shows the cart price rule, code format, audience, data field, total contacts, number of batches, and a preview of what your codes look like.

  3. Select Generate.

Magento returns you to the Dotdigital Bulk Coupons page and shows the message "Coupon job created successfully." Your new job appears at the top of the list with the status Pending.


4. Check your job

Magento processes your job in the background, in batches of 2,000 contacts. You can leave the page while it runs.

On the Dotdigital Bulk Coupons page, the job's status changes to Processing while codes are generated, then to Complete when every batch has finished. Job Details shows how many batches and contacts have been processed so far.

Once the job is complete, the codes are saved on your contacts' records in Marketing and are ready to use in your campaigns.


See also

Did this answer your question?