Using FastPixel with Cloudflare’s API Token
1 min read
To follow the instructions below, you must have access to your Cloudflare control panel. If Cloudflare was set up through your hosting provider (e.g., SiteGround, WP Engine, Kinsta, etc.), you will not be able to proceed unless they grant you access to your Cloudflare control panel. Alternatively, you can disable the Cloudflare integration with your hosting provider and set it up yourself using a free Cloudflare account.
FastPixel allows you to use a secure Cloudflare API Token in its settings instead of the Global API Key and Cloudflare account email. This integration enables our plugin to update your cache on Cloudflare as soon as the pages are optimized, ensuring that Cloudflare never serves unoptimized pages.
To create a token suitable for this purpose, you need to grant it the “Cache Purge” permission. Follow the instructions below to create it:
- Log in to your Cloudflare account, click the Profile icon in the top right section of the screen, and then click Profile.
2. Click API Tokens from the left menu, then click the Create Token button.
3. Scroll down and click the Commencer button next to the Create Custom Token tab.
4. Under Token Name, enter a descriptive internal name for the token, such as “FastPixel“.
5. Under Permissions, select “Zone” > “Cache Purge” > “Purge” from the three dropdown menus.
If you see “Edit” instead of “Purge” in the third dropdown menu, you can select that option instead.
6. Under Zone Resources, select “Include” > “Specific zone” > “Your Domain” from the three dropdown menus. Note that your site must be added to your Cloudflare account for the domain to appear in the third dropdown, as shown in the screenshot below.
If you have multiple websites, you have two options: either click the “+ Add more” link to add the desired domains, or select “All zones” from the second dropdown menu to create the token for all your websites at once.
7. Scroll down, click Continue to summary, and then click the Create Token button.
8. Copy the generated token and make sure to save it, as it will not be displayed again.
9. Paste the token code into our plugin settings (WP Admin > FastPixel > Settings > Integrations > API Token).
How to Find the Zone ID? #
- Go to your Cloudflare Dashboard
- Click the three dots next to your domain
- Click Copy Zone ID
- Paste the Zone ID into our plugin settings (WP Admin > FastPixel > Settings > Integrations > Zone ID).