How to use cookies and edge computing for content targeting

Marketing and editorial teams employ content targeting using cookies to deliver diverse experiences for users. Cookies are created for this task using JavaScript functions (client-side processing) or functions on the application backend (server-side processing), which instruct the content management application to reply with distinct content for each group of users.

It’s feasible to create, evaluate, and carry out the variation of these cookies directly on the edge by using serverless functions and edge computing. These jobs, when done on the edge, improve customer experience, application performance, distribution assertiveness, and overall operating cost by eliminating the need for an additional processing flow.


Content targeting using Azion Marketplace Content Targeting integration

Section titled Content targeting using Azion Marketplace Content Targeting integration

Content Targeting is a serverless integration available on Azion Marketplace. It allows you to create and manipulate cookies for flexible usage logics, such as content segmentation or handling specific application contexts, business rules, or any other scenario that the customer wishes to evaluate. You’ll do that by creating different scenarios, specifying variants and distribution percentages for each scenario, with greater assertiveness and without burdening resources and interactions at the source.

You can also use the processing logic in the edge, broadening the function’s applicability and reaping several benefits, such as:

  • Targeted cache.
  • Peak access absorption.
  • High performance.
  • Distributed processing logic.
  • Event registration via Data Stream.

How the Azion Marketplace Content Targeting integration works

Section titled How the Azion Marketplace Content Targeting integration works

When a request arrives at the edge, the algorithm distributes it based on the defined probability, and a cookie is established with the expiration time and the values supplied for each variant. A header can also be specified, which expands the possibilities for segmentation by Rules Engine.


In order to demonstrate a practical application for this integration, a scenario will be set, in which you want to randomly deliver four versions of a landing page through the variation of cookies. This is useful for behavior analysis later in data analytics tools (such as Google Analytics). In this scenario, the configuration file had to distribute the variants uniformly, allocating the same percentage of values to each one.

The Content Targeting integration is available at the Azion Marketplace. This integration can be accessed through Azion Console by selecting Products menu, represented by the three horizontal lines on the upper-left corner, and then Marketplace.

In order to access Azion Console, you must have an Azion account. If you don’t have one, visit the sign-up page.

Once you’ve gotten on the Marketplace homepage, you can use the search box to find the Content Targeting integration, or you can navigate through the cards until you find the Content Targeting card. Click on it to get redirected to the Content Targeting homepage. On the homepage, look for the Subscribe for section on the bottom-right corner and click the Get it now button.

You can see how to instantiate and configure the Content Targeting integration by visiting the How to install the Content Targeting integration through Azion Marketplace guide on the documentation page.

The following JSON file is an example of a basic configuration, maintaining a 25% (0.25) probability for all variants. Remember that the sum must always be 1.

{
"cookie_name": "mydomain_cookie",
"header_name": "my_header",
"domain": ".mydomain.com",
"expires": "Wed, 21 Oct 2025 07:28:00 GMT",
"max_age": 600,
"path": "/",
"values": [
{
"cache_key": "custom_a",
"value": "A",
"weight": 0.25
},
{
"cache_key": "custom_b",
"value": "B",
"weight": 0.25
},
{
"cache_key": "custom_c",
"value": "C",
"weight": 0.25
},
{
"cache_key": "custom_d",
"value": "D",
"weight": 0.25
}
]
}

After editing the JSON file, give a name to your function. In this case, it’ll be MyContentTargeting, and save it by clicking the Save button.


On the Edge Applications page, in the Rules Engine tab, you have to configure the rules you want (criteria and behavior) to apply to run your function.

To do so, follow these steps:

  1. Select the Rules Engine tab.
  2. Click on Default Rule.
    • You can’t change the criteria field for the Default Rule on Rules Engine.
  3. On the behavior field, select Run Function from the dropdown menu and then select the Content Targeting function according to the name you gave it earlier. In this case, it’ll be MyContentTargeting.
  4. Click the Save button.

Now it’s time to configure your application to deliver a different version of the landing page for each variation of cookies (if mydomain_cookie = custom_a -> then deliver landing_page_a, for example).

Follow the evolution of conversion rates, abandonment and recurrence, among other metrics in your data analytics tools (Google Analytics, for example).


Contributors