Saving product data using XML

  • Updated

You can use the XML format for the content interface paragraphs. If you choose XML, do not save your product data with the CSV solution on the Optimizely server. Instead, Optimizely Campaign retrieve product data from your web space or server using a HTTP request.

When the request is made, your product data must:

Your company's environment determines whether you import static or dynamic product data. Contact your system administrator to learn which implementation is in use.

Saving static product data on the server

To save product data statically as XML files on your webspace or server, each product must be saved in an XML file. You cannot group multiple products into a single XML file. To save a product as an XML file, perform the following steps.

  1. Open a text editor, such as Notepad (Windows) or Textedit (macOS/OS X).
  2. Create a new document.

    Set your text document to use UTF-8 character encoding. If you use another encoding, the text may not be represented properly.

  1. Copy the following code into your document.
    Code to copy
    <?xml version="1.0" encoding="UTF-8"?><element><property name="id">123456</property><property name="text1"><![CDATA[<b>Text field 1</b>]]></property><property name="text2"><![CDATA[Text field 2]]></property><property name="text3"><![CDATA[Text field 3]]></property><property name="text4"><![CDATA[Text field 4]]></property><property name="text5"><![CDATA[Text field 5]]></property><property name="text6"><![CDATA[Text field 6]]></property><property name="text7"><![CDATA[Text field 7]]></property><property name="text8"><![CDATA[Text field 8]]></property><property name="text9"><![CDATA[Text field 9]]></property><property name="text10"><![CDATA[Text field 10]]></property><property name="link1Text"><![CDATA[Text for link 1]]></property><property name="link1Url"><![CDATA[URL for link 1]]></property><property name="link2Text"><![CDATA[Text for link 2]]></property><property name="link2Url"><![CDATA[URL for link 2]]></property><property name="link3Text"><![CDATA[Text for link 3]]></property><property name="link3Url"><![CDATA[URL for link 3]]></property><property name="image1ImageUrl"><![CDATA[Image URL for image 1]]></property><property name="image1AltText"><![CDATA[Alternative text for image 1]]></property><property name="image1Link"><![CDATA[Link for image 1]]></property><property name="image2ImageUrl"><![CDATA[Image URL for image 2]]></property><property name="image2AltText"><![CDATA[Alternative text for image 2]]></property><property name="image2Link"><![CDATA[Link for image 2]]></property><property name="image3ImageUrl"><![CDATA[Image URL for image 3]]></property><property name="image3AltText"><![CDATA[Alternative text for Image 3]]></property><property name="image3Link"><![CDATA[Link for image 3]]></property><property name="image4ImageUrl"><![CDATA[Image URL for image 4]]></property><property name="image4AltText"><![CDATA[Alternative text for image 4]]></property><property name="image4Link"><![CDATA[Link for image 4]]></property><property name="image5ImageUrl"><![CDATA[Image URL for image 5]]></property><property name="image5AltText"><![CDATA[Alternative text for image 5]]></property><property name="image5Link"><![CDATA[Link for image 5]]></property><property name="image6ImageUrl"><![CDATA[Image URL for image 6]]></property><property name="image6AltText"><![CDATA[Alternative text for image 6]]></property><property name="image6Link"><![CDATA[Link for image 6]]></property><property name="additionalData1"><![CDATA[Additional information 1]]></property>
    <property name="additionalData2"><![CDATA[Additional information 2]]></property>
    <property name="additionalData3"><![CDATA[Additional information 3]]></property>
    <property name="additionalData4"><![CDATA[Additional information 4]]></property>
    <property name="additionalData5"><![CDATA[Additional information 5]]></property>
    <property name="additionalData6"><![CDATA[Additional information 6]]></property>
    <property name="additionalData7"><![CDATA[Additional information 7]]></property>
    <property name="additionalData8"><![CDATA[Additional information 8]]></property>
    <property name="additionalData9"><![CDATA[Additional information 9]]></property>
    <property name="additionalData10"><![CDATA[Additional information 10]]></property>
    <property name="additionalData11"><![CDATA[Additional information 11]]></property>
    <property name="additionalData12"><![CDATA[Additional information 12]]></property>
    <property name="additionalData13"><![CDATA[Additional information 13]]></property>
    <property name="additionalData14"><![CDATA[Additional information 14]]></property>
    <property name="additionalData15"><![CDATA[Additional information 15]]></property>
    <property name="additionalData16"><![CDATA[Additional information 16]]></property>
    <property name="additionalData17"><![CDATA[Additional information 17]]></property>
    <property name="additionalData18"><![CDATA[Additional information 18]]></property>
    <property name="additionalData19"><![CDATA[Additional information 19]]></property>
    <property name="additionalData20"><![CDATA[Additional information 20]]></property></element>

    The following steps guide you through customizing this code for your setup. Only product ID (in code, the property id) is mandatory. Other values are optional. Delete any unused values.

  2. In the first property row, enter the product ID . Insert your product ID between the brackets.

    Example: Your product has the product ID "FR123". <property name="id">FR123</property>

    Use only alphanumeric characters (letters and numbers) in the product ID. If you use special characters, you may encounter problems importing product data.

    In all steps below, you insert the value between brackets, after CDATA.

  3. In the 2nd through 11th property rows (text1 through text10), enter up to ten text elements for your product offer. "Text field 1", "Text field 2", "Text field 3" and so on are entered as placeholders for your text elements.

    The text elements can include things such as the heading for the product offer, the product name, the product category, the product description, the old price, the current price, the manufacturer/supplier, and so on. Adapt the content to your needs and your product or service's requirements.

    Example: The header of the product offer is: Relax in Paris. <property name="text1"><![CDATA[Relax in Paris]]></property>

    It is best to organize product offer components sequentially, from text1 through text10, which is how they are shown in the finished product offer. If you are not sure what order is best for you, contact customer support. The formatting (text size and text color) of the text field content is set separately using an HTML layout.

  4. In the 12th property row, enter the heading for the link to your product offer. For example: Offer, More Information or Buy Now.

    Example: The link text is: Book now. <property name="link1Text"><![CDATA[Book now]]></property>

  5. In the 13th property row, enter the URL that leads to the product page in your web shop.

    Example: The URL of the product page is <property name="link1Url"><![CDATA[]]></property>

  6. In the property rows 14 through 17, if your product offer needs more than one link, enter two additional links and link texts. Enter the information as specified in steps 6 and 7.

    Example: Next to the link to the booking page for the Paris trip, another link leads to the current weather in Paris.

  7. In the 18th property row enter the URL to the product image. Optimizely Campaign loads the product image using that URL and shows it in your message.

    Example: The URL of the product image is "". <property name="image1ImageUrl"><![CDATA[]]></property>

  8. In the 19th property row, enter the alternative text for your product image. An alternative text is the text that is shown when an image cannot be loaded. Enter alternative texts, because visually impaired people can read these using special programs, promoting an accessible Internet.

    Example: The alternative text for your product is "The Eiffel Tower in Paris in springtime". <property name="image1AltText"><![CDATA[The Eiffel Tower in Paris in springtime]]></property>

  9. In the 20th property row, enter a URL for the product image. If a recipient clicks on the image, he or she is led to the associated URL. This can be your web shop or also any other address that you want to connect to the image.

    To display the image in messages, be certain that you are using the ImageURL, which indicates the image's saved location. The ImageLink, on the other hand, directs the recipient to the link target, which has additional information.

    Example: The URL associated with your product image is: "". <property name="image1ImageUrl"><![CDATA[]]></property>

  10. In the property lines 21 through 35, up to five additional URLs for the locations where the product images are stored can be entered, and five additional alternative texts and five additional links that direct the recipient to the link target when clicked. This means: Up to six product images, each with an alternative text and a link can be associated with each product offer. Enter the information as specified in steps 9 and 11 of this manual.
  11. In the property lines 36 to 55, enter additional data records that you can use, such as metadata for the program logic of the HTML layouts.
  12. Save the text document. For the file name, use the product ID (the value you inserted for the id property). For file type, use .xml.
  13. Delete the document's file extension. For example, if the document is named ParisTrip01.xml, rename the file as ParisTrip01.

    If you do not remove the file extension, your product data cannot be loaded.

  14. Save the document in your webspace or on your server in the directory that you communicated for the setup of the product paragraph with content interface.

    Do not change the location of the product description documents without consulting customer support. If you change directories without consulting customer support, you cannot load product data using the content interface.

    When you have saved your text document in your web space or on your server, you can access your product offer in the Template Kit. Follow the individual steps in the Static XML article section to upload your product offer into the Template Kit using the content interface.

Generating dynamic product data on the server

The preparation of dynamic product data generally follows the same scheme as static product data, but the XML files are not prepared manually. Instead, they are loaded from a database when called (by HTTP request) via the content interface and automatically generated as XML. Your company needs to program this process. To generate dynamic product data, consult your system administrator.

When performing the configuration:

  1. The XML feed must be UTF-8 encoded.
  2. The product ID must be positioned at the end of the URL.