---
title: Meta Pixel Optimization
description: Host the Meta Pixel (Facebook Pixel) script on your own WordPress site with Powered Cache Premium. Learn what changes, how often it refreshes and privacy notes.
url: "https://poweredcache.com/docs/meta-pixel-optimization/"
updated: "2026-12-02"
category: Integrations
---

# Meta Pixel Optimization

Meta Pixel Optimization saves a copy of the Meta Pixel script (formerly the Facebook Pixel) and other Meta scripts on your own server, and loads that copy instead of the file on Meta's servers. The browser needs no extra connection to Meta just to download the script, and the file is served with your own server's caching rules.

**Available in:** Powered Cache Premium
**Where to find it:** Powered Cache → Integrations

## How it works

1. When WordPress builds a front-end page, Powered Cache looks through its `<script>` tags, both script files and inline code, for a JavaScript address on `facebook.net`. The standard Pixel snippet loads `https://connect.facebook.net/en_US/fbevents.js` from inline code, and the Facebook SDK loads `sdk.js`. Both are found.
2. It downloads the file and saves it in `wp-content/cache/externaljs/`.
3. It replaces Meta's address in the page with the address of the local copy, with a `?t=` parameter that changes when the copy is refreshed.

Your Pixel ID and the `fbq()` calls stay unchanged. If the download fails and no local copy exists yet, the page keeps Meta's original address. Admin screens, AJAX and REST API requests, and feeds are not changed. Files that the Pixel loads later, after it starts, still come from Meta.

### How the copy stays up to date

There is no separate schedule. When WordPress builds a page and the local copy is older than **24 hours**, Powered Cache downloads the script again and overwrites the copy. That page waits for the download. Pages served from the page cache are not delayed. If the new download fails, the existing copy stays in use. **Purge All Cache** deletes the local copies.

## Turn on Meta Pixel Optimization

1. Go to **Powered Cache → Integrations**.
2. Turn on **Meta Pixel Optimization** (*Optimize Meta Pixel scripts*).
3. Click **Save Settings**, then run **Purge All Cache** so cached pages are rebuilt with the local address.
4. View the source of a page in a private browser window. The `fbevents.js` address should now point to `/wp-content/cache/externaljs/`.
5. Check in Meta Events Manager (for example with *Test events*) that your page views still arrive.

## Settings

### Meta Pixel Optimization

Hosts Meta scripts from `facebook.net` on your server. **Default: off.** There are no other options.

> **Changed in 4.0:** this setting was called *Facebook Tracking* in Powered Cache 3.x. Only the name changed, and your saved choice was kept.

## Privacy notes

- Hosting the script file locally does **not** stop tracking. Once it runs, the Pixel sends events to Meta as before. You still need the same consent and privacy notices.
- Your server contacts Meta about once a day to refresh the copy. That request does not contain visitor data.
- If your cookie consent tool blocks the Pixel by its `facebook.net` address, the address changes to your own domain. Test that the tool still blocks the Pixel until the visitor agrees. See [cookie consent plugins](/docs/plugin-and-theme-compatibility/#cookie-consent-plugins).

## For developers

The `powered_cache_fb_tracking_ttl` filter changes the refresh age in seconds (default one day). The `powered_cache_tracking_cache_path` filter changes the storage folder. See the [Hooks Reference](/docs/hooks-reference/).

## Related docs

- [Google Tracking Optimization](/docs/google-tracking-optimization/) (Premium)
- [Delay JavaScript](/docs/delay-javascript/)
- [Clear Cache](/docs/clear-cache/)
- [Cookie consent plugins](/docs/plugin-and-theme-compatibility/#cookie-consent-plugins)
