Setting up the Cloudflare Worker integration

Setting up Log File Analysis with the Cloudflare Worker (opens in a new tab) in ContentKing is very simple! Follow the steps outlined below to enable Log File Analysis in ContentKing, and set up the Cloudflare integration.

Setting up the Log File Analysis

The process of configuring the Log File Analysis consists of two phases:

  1. Enabling the Log File Analysis feature in ContentKing

  2. Setting up the Cloudflare Worker integration

1. Enabling the Log File Analysis feature in ContentKing

If you navigate to the Account and then Websites section in ContentKing, you can easily filter and see which of the websites you are monitoring in ContentKing are on Cloudflare:

Screenshot of the website section in ContentKing

From there, just follow the steps outlined below to enable the Log File Analysis on the wanted website:

  1. Click any website that is running on Cloudflare in the Websites section (opens in a new tab) of ContentKing
  2. Click on the Log File Analysis in the Settings section
  3. Move the Log File Analysis toggle to Enabled state

2. Setting up the Cloudflare Worker integration

To connect ContentKing to Cloudflare, you will need to create an API token in your Cloudflare account.

Using this token, ContentKing will automatically install its Cloudflare Worker for this website without any additional configuration required from your side. Using the Cloudflare Worker ContentKing will be able to detect and track visits of search engines to this website.

Creating a Cloudflare token

Follow these steps to create a Cloudflare token:

1. Go to your API tokens in your Cloudflare account

Log in to your Cloudflare Dashboard (opens in a new tab) and go to "User Profile" -> API Tokens (opens in a new tab).

Screenshot of the API Tokens button on the Cloudflare dashboard
2. Click "Create token"

On the "API tokens" screen, click "Create token".

Screenshot of the box for creating a new API token
3. Choose a custom token

Click "Get started" in the "Custom token" section at the bottom of the screen.

Screenshot of the API Tokens section for creating a custom token
4. Set the permissions

To let ContentKing automatically install the Cloudflare Worker, set the following permissions for the API token:

  • On Account-level: Workers Scripts: Edit
  • On Zone-level: Workers Routes: Edit
  • On Zone-level: Zone: Read
Screenshot of the box for setting the permissions for the API token
5. Include relevant "Account" and "Zone"

Make sure to include the appropriate "Account" and "Zone" for the websites you want to enable the Log File Analysis feature for.

Screenshot of the box for including the appropriate account and zone

If you enabled Log File Analysis for a website in your account, and you want to enable it on another website that is in the same Cloudflare account, the Cloudflare token that you are generating for the new website needs to include relevant “Account” and “Zone” for both websites.

This is due to the fact that currently only one Cloudflare Worker can be installed in a single Cloudflare account, which means that the generated token always needs to have permissions for all websites on which you want to use the Log File Analysis.

6. Optional - Define the validity of the token

Important: Immediately after the Cloudflare Worker is installed, ContentKing will discard the API token.

However, you can optionally also limit the validity of the token on the Cloudflare side, e.g. by setting the "Start Date" to today and "End Date" to tomorrow.

Screenshot of setting up the TTL option for the validity of the token

Enter the generated token to ContentKing

Once you create the API token following the steps above, enter it to the modal for connecting Cloudflare (opens in a new tab) in ContentKing:

Screenshot of connecting Cloudflare through the ContentKing modal

Afterwards, ContentKing will automatically install the Cloudflare Worker and start tracking the search engine traffic on this website.

If you want to learn how to work with the Log File Analysis data in ContentKing, refer to our support article: Working with the Log File Analysis data in ContentKing

Reinstalling the Cloudflare Worker

If there is a need to reinstall the Cloudflare Worker on any of your websites, you can do it in the following way:

  1. Generate a new Cloudflare token following the steps above
  2. Click on the website on which you want to reinstall the Cloudflare Worker in the Websites section (opens in a new tab) of ContentKing
  3. Click on the Log File Analysis in Settings, click on the Edit button in the Log Sources block and then reinstall
  4. Enter the new token and click install

Disabling Log File Analysis

Same as with enabling Log File Analysis, you need to disable the feature in ContentKing and then remove the Cloudflare Worker.

Disabling Log File Analysis in ContentKing

  1. Click on the website on which you want to disable Log File Analysis in the Websites section (opens in a new tab) of ContentKing
  2. Click on the Log File Analysis in the Settings section
  3. Move the Log File Analysis toggle to Disabled state

Removing the Cloudflare Worker

If you have disabled the Log File Analysis feature, you still need to uninstall the Cloudflare Worker in your Cloudflare account.

The reason why ContentKing doesn’t do this automatically is that after the Cloudflare Worker is installed, for security reasons ContentKing forgets the API token. Therefore, ContentKing has no way of uninstalling the Cloudflare Worker.

For the most common security related questions about ContentKing's Log File Analysis, refer to the FAQ section in the Log File Analysis support article

Need help?

In case you have any questions regarding the Cloudflare Worker integration that are not covered by our documentation, don’t hesitate to contact us!