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 #
- When WordPress builds a front-end page, Powered Cache looks through its
<script>tags, both script files and inline code, for a JavaScript address onfacebook.net. The standard Pixel snippet loadshttps://connect.facebook.net/en_US/fbevents.jsfrom inline code, and the Facebook SDK loadssdk.js. Both are found. - It downloads the file and saves it in
wp-content/cache/externaljs/. - 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 #
- Go to Powered Cache → Integrations.
- Turn on Meta Pixel Optimization (Optimize Meta Pixel scripts).
- Click Save Settings, then run Purge All Cache so cached pages are rebuilt with the local address.
- View the source of a page in a private browser window. The
fbevents.jsaddress should now point to/wp-content/cache/externaljs/. - 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.netaddress, the address changes to your own domain. Test that the tool still blocks the Pixel until the visitor agrees. See 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.