braekling / WP-Matomo

Official WP-Matomo (former WP-Piwik) repository
GNU General Public License v3.0
30 stars 28 forks source link

Multisite: Manually entered tracking code not rendered, default code instead #71

Open tyrann0us opened 6 years ago

tyrann0us commented 6 years ago

Steps to reproduce

  1. Create WordPress Multisite
  2. Change WP-Piwik's Add tracking code: to Enter manually
  3. Make changes to the tracking code

Current behavior

The modified tracking code is saved successfully into the database (reloading the options page shows the correct code) but the default, not modified code is rendered into the page (open website in incognito mode to verify).

Expected behavior

The modified tracking code should be rendered into the page.

Possible solution

get_site_option( 'wp-piwik-manually' ) (called here: https://github.com/braekling/WP-Matomo/blob/master/classes/WP_Piwik/TrackingCode.php#L17 if in Multisite environment and tracking method set to "manually") seems to return the default tracking code, while self::$wpPiwik->getOption ( 'tracking_code' ) returns the correct one. It seems the ternery if statement is wrong.

Context (Environment)

WordPress v4.9.6 (based on Bedrock) WP-Piwik v1.0.19

Any feedback on this is highly appreciated! Especially in the light of the upcoming GDPR law which might force site owners to load the tracking code only if the user has opted in.

tyrann0us commented 6 years ago

@braekling, any chance to take a look at this? It currently prevents us from deploying GDPR compliant tracking opt out functionality on our customers websites. Thanks!

braekling commented 6 years ago

I'm currently working on a new update and will also have a look at your issue.