Campaign Design API > Reducing the cookies size

Who is this article for?

  • Web Developers who build Maxymiser campaigns
  • Marketers working closely with Web Developers

Maxymiser cookies

Oracle Maxymiser's Campaign Design API (CD API) uses browser's 1st-party cookies on your site to store visitor-specific information. More details about what data is stored in the cookies can be found in Oracle Maxymiser Cookies Explained.

Challenge: cookie size growth over time

There are two possible cookie-related issues visitors may experience on your site over time due to cookie size growth:

  1. GET request (including all the headers such as cookies) becomes too large for the server (the limit is usually set to 8kb);
  2. Single cookie size can be too long for a browser (4kb for Chrome).
1st-party cookies are managed by the server, internal JavaScript libraries and 3rd party scripts like Maxymiser's. All of these can contribute to the issue with overall cookie size so it is important to know how to optimize the use of cookie storage. This article includes tips on how to reduce the size and optimise storage in the Maxymiser cookies.

Optimizing the overall size of Maxymiser cookies

In case you experience excessive increase of the Maxymiser cookies' size, you can do the following:

1. Switch from "cookie" storageType to "cookie-key-value"

CD API uses one of the following cookie structures:

  • "cookie" (default) – all the testing-related data is stored in two centralized JSON trees;
  • "cookie-key-value" – every storage item is saved as a separate cookie.

"cookie" format requires more space to contain all the data in one structure (JSON tree holds expiration values for every storage item and requires additional encoding); "cookie-key-value" can reduce Maxymiser cookies size up to 30%.

More information on the cookie storage is available at Oracle Maxymiser Cookies Explained.

Storage type can be configured as described in the Guide's Appendix section – Configuring the JavaScript library.

2. Decrease number of active Campaigns per visitor

CD API stores historic data about past campaign visits and actions tracked in the "pd" storage cookie. With that in mind, we recommend the following:

  • Minimize the number of campaigns running on a page at the same time or use Master campaigns to split traffic between those;
  • Implement winning variant within the site and stop the campaigns that serve the winners as soon as possible – they persist the winning experiences info in the profile and contribute to its size growth;
  • Reduce the number of MaxEngage Campaigns.

3. Review test logic and use of CD API

The CD API methods listed below can be used to store complex data structures that do not necessarily belong to cookies. For everything more complex than a number or a word we recommend using the browser's localStorage.

Depending on the campaign configuration for a specific visitor, the size of cookies will be affected by the following CD API calls:

  • visitor.storeAttr() method

    Description: Stores Custom Attributes values

    Recommendations:

    • For attributes only relevant to a single campaign running on the same page where an attribute can be set use visitor.setAttr() when possible:

      /* Good practice */ visitor.setAttr('SeenOffer', window.visitorSeenAds); // sets attribute value for the next request renderer .getContent('T48') // request .always(function() { renderer .runVariantJs() .showAll(); });
    • Refrain from storing long attribute names or values:

      /* Bad practice */ visitor.storeAttr('GenPage', location.pathname); // use either visitor.setAttr() or a shorter value
    • Maintain visitor.storeAttr() calls to avoid situations of a live script tracking a Custom Attribute that has been removed or modified in the Maxymiser UI. In case Custom Attributes data becomes meaningless in the storage, consider cleaning it up with a dedicated script:

      /* Good practice */ visitor.removeAttr('SeenOffer');

  • visitor.storeId() method

    Description: Stores external identifier values

    Recommendations:

    • External id value can be quite long, so it is recommended to either transform it to a short string or use visitor.setId():

      /* Bad practice */ visitor.storeId(1, '3a234s-D3K2Sv-S5DF7P-68oiS6-78ZF6-48eNF5-9F8SD7'); /* Good practice */ visitor.storeId(1, 'D3K2Sv');

    • Maintain visitor.storeId() calls to avoid outdated visitor id tracking. Consider removing the data when an identifier becomes obsolete:

      /* Good practice */ visitor.removeId(1);

  • campaign.setData() and visitor.setData() methods

    Description: Stores custom data to be used in the scope of the campaign

    Recommendations:

    • Store short strings or numbers:

      /* Identify the most viewable site category */ var i = 0, // 'CatVisits' data item is as small as possible, i.e. 5 bytes recordedVisits = (visitor.getData('CatVisits') || '00000').split(''), categories = ['Bikes', 'Tires', 'Lights', 'Handlebars', 'Pedals']; while ( categories[i] !== window.categoryName && i < categories.length ) { i++; } recordedVisits[i] = recordedVisits[i] * 1 + 1; if (recordedVisits[i] > 9) { recordedVisits[i] = 9; } visitor.setData('CatVisits', recordedVisits.join(''), 15);

    • Set data expiration appropriately:

      /* Bad practice */ campaign.setData('MenuClick', 'Yes', 999); /* Good practice */ campaign.setData('MenuClick', 'Yes', 0); // passed later to an action tracked in the same session

    • Consider cleaning up data if needed:

      /* Good practice */ campaign.clearData('CatVisits');

  • actions.postpone() method

    Description: Stores action data till the next request to Maxymiser (usually it's the next page load), may be inappropriately used to store long strings

    Recommendations:

    • Store short strings:

      // Good practice actions.postpone('NavClick', 1, 'Top'); // Bad practice var linkCaption = $(this).text(); // "Bikes and Tires – choose the best products that fit your lifestyle" actions.postpone('MenuItemClick', 1, linkCaption);