Configuring transactional mails

This topic is for administrators and developers with administration access rights in Shopware.

This topic describes how to configure sending of transactional mails An email triggered by a recipient action (such as an order or purchase) or event (such as an anniversary). It is sent out subsequent to the event. when using Shopware as e-commerce platform with Optimizely Campaign.

How it works

Sending of transactional mails uses these templates:

The sending and receiving of the content of the variables use the transaction recipient list as a buffer.

  1. The Shopware template sends the variables.
  2. The variables are written into the transaction recipient list: each variable into the relevant recipient list field.
  3. Using field functions, Optimizely Campaign copies the template with the individual variables from the transaction recipient list and places it in the desired location in the transactional mail.

    Image: Sending and receiving content of variables

Configuration steps

  1. Set up the transaction recipient list.
  2. Configure the template in Optimizely Campaign.
  3. Configure the template in Shopware.
  4. Configure the details of transaction mails.
  5. Set up the transactional mails for multiple shops.

Step 1. Setting up a transaction recipient list

To set up a transaction recipient list, contact customer support. Plan in advance which variables you want to transfer from Shopware into Optimizely Campaign for your transactional mails.

List the Shopware variables for which you require a corresponding recipient list field in your transaction recipient list. Also, let Optimizely know the naming of the recipient list fields.

Step 2. Creating a template in Optimizely Campaign

Create the template and add the desired transactional mail texts (the unchangeable, static texts to be sent to recipients) and insert field functions in the places where the content of the Shopware variables should be.

About field functions

Field functions are placeholders that refer to a specific recipient list field in your transaction recipient list. The variables and content of the variables sent from Shopware are written into the relevant recipient list fields in your transaction recipient list. The field functions you place load relevant content from the referenced recipient list field in the next step.

Example

Set up a transactional mail text that greets each customer using the last name and the order date. For this you need these variables: salutation, lastname and orderdate.

The content of the variables is first written to a relevant recipient list field of the transaction recipient list (from Shopware via the HTTP API). To access these recipient list fields, insert the individual field functions into the Optimizely Campaign template and place the name of the recipient list field in curly brackets. To import the variable contents, the static text and field functions in the Optimizely Campaign template could look like this:

Hello, {salutation} {lastname}! Thank you for your online order from {orderdate}.

The example will appear in the sent transactional mail as follows:

Hello, Mr. Miller!
Thank you for your online order from August 3.

To create the template, do the following:

  1. Open the Optimizely Campaign menu and select Campaigns > Transactional Mails.
  2. Click Create….

    Image: Create transactional email

  3. Drag the Recipients node from the left action area to the working area on the right.
  4. In the Recipient lists drop-down list, select your transaction recipient list.

    Image: Selecting transaction recipient list

    Customer support sets up a separate transaction recipient list for you. Be sure you use this transaction recipient list, instead of a regular recipient list. To see if a recipient list is a transactional recipient list, check the column Transaction API.

  5. From the left action pane, drag the message node for the desired marketing channel Channel through which advertising messages or information are transmitted to customers and prospects. For example, email, SMS, print or push. (email, SMS) into the workspace.
  6. In the Name box, assign a concise name to your transactional mail (such as Order confirmation).

    Image: Edit confirmation name

  7. In the context menu for the message node, click Edit Content….
  8. In the Template drop-down list, select the desired template and confirm your selection by clicking Next.
  9. Configure the template for the transactional mail according to your requirements. Enter a subject and insert the static texts that you want recipients to receive, into the content paragraphs. Insert the relevant field function for the recipient list field of the transaction recipient list into places where variables from the Shopware template should appear (see the previous example in this topic).
  10. Click Close.
  11. Connect the Recipient node with the message node.
  12. Click Save and Close.
  13. To activate your transactional mail and to start the sending process, select the mailing in the overview and click Start.

Step 3. Configuring the template in Shopware

Configure a transactional mail template that sends variables to Optimizely Campaign via the HTTP API.

Prerequisites

  • Authorization code for your transaction recipient list in to Optimizely Campaign. To see the authorization code, open the Optimizely Campaign menu and select AdministrationAPI Overview. Open the Recipient lists tab and select the desired transaction recipient list. Click Manage authorization codes and copy the authorization code from the list. If no authorization code is available for the selected recipient list, click Create authorization code.
  • The mailing ID for the template in Optimizely Campaign. To see the mailing ID, open the the Optimizely Campaign menu and select CampaignsTransactional mails. Copy the relevant mailing ID of the template in the list in column ID.

The Shopware integration contains two functional templates for demonstration purposes:

  • sREGISTERCONFIRMATION
  • sORDER

Do not use the system template sOPTINNEWSLETTER, which is included in the Shopware standard, to set up the newsletter registration. If you do, newsletter registration with Optimizely Campaign will not work.

  1. Log in to the back-end of your Shopware system with administrator rights.
  2. Go to Configuration > Email templates.

    Image: Email templates menu item

  3. Go through the directory structure to the template that you want to configure.

    Image: Select template

  4. To send the template variables to Optimizely Campaign via the HTTP API, select optivo broadmail ("Send with optivo broadmail").

    Image: Select template variable

  5. In the optivo authcode box, enter the authorization code of your transaction recipient list in Optimizely Campaign.

    Image: Enter authcode

  6. In the optivo bmMailingId box, enter the mailing ID of the template in Optimizely Campaign.

    Image: Enter mailing ID

  7. Open the optivo broadmail tab.

    Image: optivo broadmail tab

    If the mailing is activated via Optimizely Campaign, the field values in the tabs Plaintext, HTML-Text, and Attachments are ignored.

  8. In the fields of the optivo broadmail tab, map the Shopware variables with the corresponding recipient list fields in your transaction recipient list to Optimizely Campaign. To see available variables for the respective template, click Sample variables.

    Image: View variable information 1

    Image: View variable information 2

    Mapping ("Assigning")

    The Shopware integration from Optimizely Campaign uses the following structure for mapping:

    Name of the recipient list field=name of the Shopware variable

    Enter the mapping assignment for each variable line-by-line, and end each line with a semicolon. Separate the individual variables/mapping assignments with line breaks.

    Example:

    salutation={salutation};
    firstname={firstname};
    	lastname={lastname};
    	smail={sMAIL};
    	shopname={config name=shopName};

    Use the example lines to map and transfer:

    • Shopware variable value {salutation} to transaction recipient list field salutation
    • Shopware variable value {firstname} to transaction recipient list field firstname
    • Shopware variable value {lastname} to transaction recipient list field lastname
    • Shopware variable value {sMAIL} to transaction recipient list field smail
    • Shopware variable value {config name=shopName} to transaction recipient list field shopname

    Make sure that you map the Shopware variables to be transmitted to existing recipient list fields. Contact customer support to set these up. Determine in advance which data/content to transfer to Optimizely Campaign, and which content you can implement as static text in the Optimizely Campaign template.

  9. Click Save template.

Step 4. Configuring transactional mails

The language template in Shopware writes the ordered products as a character string to the recipient list field orderPositions in the transaction recipient list. In the template sORDER, which contains the Shopware integration by default, you will find the following line next to the standard customer data:

orderPositions={foreach item=details key=position from=$sOrderDetails}
  "{$details.ordernumber}"{literal};{/literal} 
  "{$details.quantity}"{literal};{/literal} 
  "{$details.price} EUR"{literal};{/literal} 
  "{$details.amount} EUR"{literal};{/literal} 
  "{$details.articlename}"{literal};{/literal}{/foreach};

The foreach loop summarizes ordered products in a character string in CSV Stands for "comma-separated values"; tabular data in a plain text file separated by the comma character. format. The individual columns (order number, quantity, price, total price, and article name) are separated by semicolons. The individual products are separated by line break characters.

Adjusting the foreach loop

  1. Go to Configuration > Email templates.
  2. Go to the supplied template sORDER in the System emails directory of the Shopware integration.
  3. Open the optivo broadmail tab.
  4. Make changes in the mapping instruction line for the recipient list field orderPositions. For example, replace EUR with another currency, such as USD.

    If you have good knowledge of Shopware template features, you can also use these functions to configure data to be transmitted. Observe the correct masking of special characters when making adjustments. In addition, the masking of the separator (semicolon) with {literal} must be retained within the loop.

  5. Click Save template.

Creating a field function for ordered products

To use the ordered products that are transmitted as a character string in a transactional mail, you need a specific field function in your client. This must use the template engine from Optimizely Campaign to transfer the character string to HTML, and to display ordered products in a table inside the transactional mail.

  1. Open the Optimizely Campaign menu and select Administration > Field Functions.

    If Field functions is not available in your client, contact customer support to enable this feature.

  2. Click Create….

    Image: Add field function

  3. Under General, in the Name field, enter a name for the new field function, such as CSVOrderObjects.

    Image: Enter field function name

  4. In the Type drop-down list, select Velocity.
  5. In the Default replacement tab in the Content area, enter the following code in the Default replacement field.
    <table>
        <tr>
            <td>Product ID</td><td>SKU</td><td>Name</td><td>Quantity</td>
            <td>Price</td>
        </tr>
    #set ($csvContent = $csv.readFromString($user.data.orderpositions))
    #foreach($row in $csvContent)
        <tr>
    #foreach($item in $row)
            <td> $item </td>
    #end
        </tr>
    #end
    </table>

  6. Click Save.

    If you have HTML knowledge, you can customize the layout of the table. See Field functions.

Step 5. Setting up transactional mails for multiple shops

If you have additional sub-shops in different languages in Shopware, you can set up individual templates in multiple languages to send transaction mails. You may need separate transaction recipient lists, contact Optimizely customer support in advance.

You may for example want to set the registration confirmation language for your newsletter to English for non-German-speaking recipients. Insert the English translation into the template, and use the corresponding field functions created for the English-speaking customers, in the places where the content of the variables provided by Shopware is to be used. If you do not have any field functions for international parameters in your client, contact customer support.

  1. Configure an individual template for transactional mails in Optimizely Campaign as described in Create a template in Optimizely Campaign.
  2. Log in to the back end of Shopware using administrator rights.
  3. Go to Configuration > Email templates.
  4. To find the desired template, go through the list on the left.
  5. In the text box, click the globe icon.
  6. Select the sub-shop or the language version for the shop from the menu bar on the left.
  7. In the optivo authcode box, enter the authorization code for the corresponding transaction recipient list in Optimizely Campaign.
  8. In the optivo bmMailingId box, enter the mailing ID of the individual template you want to use in Optimizely Campaign.
  9. Click Save translations.