Title: PHP API mode &amp; autoptimize enabled breaks many website functionalities
Last modified: January 27, 2022

---

# PHP API mode & autoptimize enabled breaks many website functionalities

 *  [Thanatermesis](https://wordpress.org/support/users/thanatermesis/)
 * (@thanatermesis)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/)
 * I wanted to try “PHP API” mode instead of “HTTP API” for a possible performance
   improvement (WordPress and matomo are installed on the same machine & user), 
   but after that I was seeing many functionalities broken on my website, the reason
   is that when using this option instead of the other one, and then I enable autoptimize
   with any of its options (it works fine with the other wp-piwik mode), something
   happens that many Content-Security-Policy are added not allowing features like
   googlefonts, youtube embed, etc…
 * More details of this issue already discussed in autoptimize: [https://wordpress.org/support/topic/no-statistics-after-activation/](https://wordpress.org/support/topic/no-statistics-after-activation/)
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-api-mode-autoptimize-enabled-breaks-many-website-functionalities%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [Thanatermesis](https://wordpress.org/support/users/thanatermesis/)
 * (@thanatermesis)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15300326)
 * In “Enable Tracking” options, seems like the bug happens using all the options**
   except** “Disabled” and “Enter manually”. Now, “Enter manually” -actually- inserts
   the tracking code just like the other options, but with this one, the bug doesn’t
   happen, what changes using this one instead of the other ones?
 * How to reproduce the issue:
    * set wp-piwik to use “PHP API” and “Default Tracking”
   mode * install “autoptimize” plugin (use any options on it) * Bug: you will see
   many “content-security-policy” errors in the console, features not working on
   the website, and **statistics** not working at all * switch to “enter manually”
   tracking code to compare that with this option there’s no bug
 *  Plugin Author [braekling](https://wordpress.org/support/users/braekling/)
 * (@braekling)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15339333)
 * I don’t know how this autoptimize plugin works, but if I got it right, it touches
   the JavaScript code on a page. So I have no idea how it may affect the PHP mode…
   it is just used to communicate with Matomo, but does not change the tracking 
   code.
 * Do you have some further information about the error messages you get? The examples
   you posted in the other thread are related to Youtube and not Matomo.
 * By the way, I’m not sure if it is a good idea to minify, cache or aggregate the
   tracking code. Is it possible to exclude it from autoptimize?
 *  Thread Starter [Thanatermesis](https://wordpress.org/support/users/thanatermesis/)
 * (@thanatermesis)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15339482)
 * Yes it touches the JS for optimization.
 * The example on the other thread is a single example of errors, on this case was
   about Youtube, but it affected many other things (matomo, youtube, google fonts,
   google analytics, etc…). This issue only happens when I use “default tracking
   mode” on matomo but not when I use “enter manually”
 * Yes I have tried to exclude it from autoptimize but the bug stills present, which
   is quite strange
 *  [vladimir-slonska](https://wordpress.org/support/users/vladimir-slonska/)
 * (@vladimir-slonska)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15378594)
 * Hello,
 * I have the same problem, but without autoptimize or others plugins. This plugin
   seems to insert a Content Security Policy header somewhere and it breaks every
   external resource :
 * default-src
    ‘self’ ‘unsafe-inline’ ‘unsafe-eval’; img-src ‘self’ ‘unsafe-inline’‘
   unsafe-eval’ data:;
 * In my case, it blocked my external fonts. I disabled all plugins, and I have 
   the problem by reactivating WP-Matomo Integration (WP-Piwik) alone.
 * And you can’t change it by adding your own rules as CSP rules are always applied:
   if something blocks it will block whatever you can add after.
 * I don’t know where it comes from, but it is necessary to remove this set of CSP
   rules I think.
 * Thank you !
 *  [vladimir-slonska](https://wordpress.org/support/users/vladimir-slonska/)
 * (@vladimir-slonska)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15378609)
 * And also, another thing : the problem doesn’t occur when I am logged as admin…
 *  [Philippe Cadu](https://wordpress.org/support/users/philapho/)
 * (@philapho)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15406351)
 * Hello
    I have the same problem as [@vladimir-slonska](https://wordpress.org/support/users/vladimir-slonska/)
   I deactivated Matomo from my two pro sites. I kept it in test on a site while
   waiting that the problem is solved. It’s a pity to have to put Google analytics
   back because the so called alternative to Analytics doesn’t work I hope a solution
   will be found soon. Sincerely Philippe

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP API mode & autoptimize enabled breaks many website functionalities’
is closed to new replies.

 * ![](https://ps.w.org/wp-piwik/assets/icon-256x256.png?rev=3467966)
 * [Connect Matomo - Analytics Dashboard for WordPress](https://wordpress.org/plugins/wp-piwik/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-piwik/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-piwik/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-piwik/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-piwik/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-piwik/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Philippe Cadu](https://wordpress.org/support/users/philapho/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/php-api-mode-autoptimize-enabled-breaks-many-website-functionalities/#post-15406351)
 * Status: not resolved