Cloudflare

Cloudflare Edge-side personalization

You can use Cloudflare to classify visitors and execute personalization instructions on the edge. This approach gives you the user experience benefits of server-side rendering with the performance and scalability benefits of a CDN.

tip

For more information about the benefits of executing personalization using Akamai EdgeWorkers, see the overview of edge-side personalization.

Before you start

You must have the following available to complete the instructions in this section:

  1. Administrator access to Cloudflare Dashboard. You can use their free tier if you don't have an account.
  2. Ability to clone a GitHub repository.
  3. Node.js v16+ installed locally.
  4. An application with edge-side personalization activated.
  5. Npm access token from Uniform. Edge-side personalization requires private packages. If you don't have an access token, contact us.

Cloudflare Wrangler is a CLI enables you to send commands to Cloudflare without having to log into the Cloudflare dashboard. Entering commands on the CLI is faster than having to navigate through a lot of different screens in the dashboard.

  1. Install Wrangler.
  2. Authenticate to Cloudflare.

Next steps

Now you are ready to create the Cloudflare Worker, which is the component that executes the personalization instructions exposed by your front-end application.

You have two options for writing the Cloudflare Worker. You can build it from scratch or use a functional example provided by Uniform.

  1. Create a file .env with the following environment variables:

    Variable nameValue
    UNIFORM_PROJECT_IDThe Uniform project whose manifest is retrieved.
    UNIFORM_API_KEYThe Uniform API key used to retrieve the manifest.
  2. In the file wrangler.toml, you must set the value for account_id. This must match your Cloudflare account ID You can retrieve this value by entering the following command on the CLI:

  3. In the file wrangler.toml, you must set an environment variable to identify the origin (such as the web server that's hosting your front-end application). You must add a new section to the file:

    About this step

    While the variable name suggests this value should be a URL, it really must be the host name for the origin. For example, if the origin is located at https://some-origin.com, the value should be some-origin.com.

You can use Wrangler to run the Cloudflare Worker locally. This enables you to test and debug without having to deploy to Cloudflare.

  1. Enter the following command on the CLI:

    About this step

    This starts a local web server that hosts the Cloudflare Worker.

  2. Open your browser to the endpoint shown in the console.

  1. Enter the following commands on the CLI:

    About this step

    These commands build and publish your Cloudflare Worker to Cloudflare.

Next steps

Now that you have Cloudflare delivering edge-side personalization, you might want to take advantage of another feature available when you run personalization on Cloudflare: location-based personalization.