How to install the Content Targeting integration through Azion Marketplace

Azion Content Targeting is a serverless integration from Azion Marketplace.

This integration allows you to manipulate cookies and headers for flexible usage logics. This function can handle specific application contexts, business rules, or other customer-defined scenarios, as well as content segmentation.

You can create different scenarios and define variants and distribution percentages for each scenario using the Content Targeting integration. This allows a greater assertiveness without taxing resources and interactions at the source. Furthermore, you can create processing logic at the edge, broadening the function’s application possibilities and reaping benefits such as targeted cache, absorption of access peaks, high performance, distributed processing logic, and event registration via Data Stream.


To use the Content Targeting integration provided at Azion Marketplace, follow these steps:

  1. Access Azion Console and go to Marketplace.
  2. On the Marketplace homepage, look for the Content Targeting card and select it.
  3. On the integration’s page, click the Get It Now button to install it.

A successful message appears to confirm your integration is installed.


Once you’ve gotten your integration on Marketplace, you’ll have to select an edge application to use the integration.

To configure your integration, proceed as follows:

  1. On the upper-left corner, select Products menu > Edge Application on the BUILD section.
  2. On the listing page of your edge applications, select the one you want to use with the Content Targeting integration.
  3. On the application page, in the Main Settings tab, locate and click the Edge Functions switch to enable edge functions on your edge application.
  4. Click the Save button.

You’ll receive a successful message indicating your edge application was updated.


To enable this function, while still on the Edge Application page:

  1. Select the Functions tab.
  2. Click the Add Function button.
  3. Choose an easy to remember name for your function.
  4. On the dropdown function menu, select the Content Targeting [Global] function.

This action will load the function, showing a form with the function’s code and, just above it, two tabs: Code and Args. Click on the Code tab and you’ll be able to navigate through the code, but won’t be able to change it. On the Args tab, you’ll pass the integration parameters.

You’ll pass the parameters via the Args tab in a JSON file that will look like this:

{
"cookie_name": "azion-cookie",
"header_name": "azion_header",
"domain": ".azion.com",
"max_age": 600,
"expires": "Tue, 19 Jan 2038 03:14:07 GMT",
"path": "/",
"values": [
{
"value": "A",
"weight": 7.1,
"cache_key": "custom_a"
},
{
"value": "B",
"weight": 14.9
}
]
}

Where:

KeyData FormatRequiredDescriptionNotes
cookie_nameStringYesRepresents the cookie which will be used to store the chosen value-
header_nameStringYesRepresents the header which will be used to store the chosen value-
domainStringYesDefines the domain for which the cookie will be set-
max_ageIntegerNoDefines how long (in seconds) the cookie value will be validWhile max_age and expires aren’t require, it’s highly recommend using at least one of them, otherwise the cookie won’t be stored.

Another important fact is that these field don’t replace one another, in fact, the expires one is just a fallback for older browsers which still doesn’t work with the max_age directive.
expiresStringNoLegacy way to define how long a cookie will be stored.

When using this format you must input a complete date.
-
pathStringYesDefines the path to where the cookie will be valid-
valuesObjectYes (the list must have at least one entry)Describes each possible value to be chosenvalue (required) represents the value which will be set in the cookie/header if this option is chosen.

weight (required) defines the odds of the option being chosen.

cache_key (optional) defines a custom cache key for the request whenever this option is chosen.

Configuring a rule on Rules Engine

Section titled Configuring a rule on Rules Engine

Now you have to configure the rules you want (criteria and behavior) to apply to run your function.

Still in the Edge Applications page, 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.
  4. Select the Content Targeting function, according to the name you gave it in the instantiation step.
  5. Click the Save button.

Done. Now you have your Content Targeting function running on the edge.


For more information about how to use the Content Targeting integration, visit the Use Case at Using cookies and logic from Edge Computing for content-targeting.


Contributors