Current Page

Current Page

Mar 6, 2024

Manual Cloudflare Worker Installation

How to manually install OptimalUX worker in your Cloudflare account.

Prerequisites

  • You need access to the Cloudflare Dashboard at “Cloudflare Workers Admin” or “Administrator” level.

Installation

Open Cloudflare dashboard and click on “Workers & Pages” in the left menu. This should take you to an overview page. Click “Create application” button.

Click “Create Worker” button, enter the name of your worker and click “Deploy”. You will be able to update the code in the following steps.

To upload worker code click “Edit code”. Copy the worker code into “worker.js” tab and click “Save and deploy”‍

Configuration

Open Cloudflare dashboard and click on “Workers & Pages” in the left menu. This should load a list of workers. Choose Optimal UX’s worker in the list and go “Variables” in “Settings” tab:

Set 2 environment variables that will allow the worker to authenticate in OptimalUX:

  • OPTIMALUX_SITE_ID

  • OPTIMALUX_SECRET

Values for those variables can be found on https://app.optimalux.com/ in site details.

The next important step is to make sure worker is invoked on incoming requests. Click “View” in Routes section:

Click “Add route” and enter desired route. To enable OptimalUX for all requests enter *example.com/*. Here are few alternative examples:

For any page on a top level domain only: example.com/* or www.example.com/*

For any page on subdomains only: *.example.com/*

(Please replace example.com with your domain name)

Note, that /* is required at the end of the route name.

Choose your domain in “Zone” dropdown and click “Add route”.‍

Testing

You should be able to check if the worker is installed and configured by using https://example.com/_optux/ping/[site_id].

The endpoint requires “Authorization” header with site’s secret key for authentication.‍

curl https://example.com/_optux/ping/site123 -H "Authorization: mypassword@123"

200k free users on the house!

Jumpstart your A/B testing with 200k free users

We don't like giant flat rates! So we're giving you 200k free users each month. After that, only $1 for every 1000 unique visitors who participated in an A/B testing.

Stacey O.

Alex V.

Thomas P.

* Introductory pricing for the next 100 customers only!

200k free users on the house!

Jumpstart your
A/B testing with 200k free users

We don't like giant flat rates! So we're giving you 200k free users each month. After that, only $1 for every 1000 unique visitors who participated in an A/B testing.

* Introductory pricing for the next 100 customers only!

200k free users on the house!

Jumpstart your A/B testing with 200k free users

We don't like giant flat rates! So we're giving you 200k free users each month. After that, only $1 for every 1000 unique visitors who participated in an A/B testing.

Stacey O.

Alex V.

Thomas P.

* Introductory pricing for the next 100 customers only!

200k free users on the house!

Jumpstart your A/B testing with 200k free users

We don't like giant flat rates! So we're giving you 200k free users each month. After that, only $1 for every 1000 unique visitors who participated in an A/B testing.

Stacey O.

Alex V.

Thomas P.

* Introductory pricing for the next 100 customers only!