diff --git a/JsTrackerForceAsync.php b/JsTrackerForceAsync.php new file mode 100644 index 0000000..cd06b36 --- /dev/null +++ b/JsTrackerForceAsync.php @@ -0,0 +1,24 @@ + array('function' => 'makePiwikJsLoadSync', 'after' => true), + ); + } + + public function makePiwikJsLoadSync(&$codeImpl, $parameters) + { + $codeImpl['loadAsync'] = true; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..7b34740 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Piwik JsTrackerForceAsync Plugin + +## Description + +This plugin is especially useful in combination with our [A/B Testing](https://plugins.piwik.org/AbTesting) feature +if you embed the tracking code directly in your website using the `SitesManager.getJavascriptTag` [HTTP API](https://developer.piwik.org/api-reference/reporting-api) method. + +When you use A/B Testing and have at least one active experiment for your website, the JavaScript code will load +synchronously to prevent the content to flickr. If you still want to load the Piwik JavaScript Tracking code async, +you can install this plugin and it will make sure to always generate the async code. \ No newline at end of file diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..beba19e --- /dev/null +++ b/plugin.json @@ -0,0 +1,23 @@ +{ + "name": "JsTrackerForceAsync", + "description": "Forces the JavaScript Tracker to always load asynchronous when embedding the Tracking Code via HTTP API automatically.", + "version": "3.0.0", + "theme": false, + "require": { + "piwik": ">=3.0.0-b1,<4.0.0" + }, + "authors": [ + { + "name": "InnoCraft", + "email": "contact@innocraft.com", + "homepage": "https://www.innocraft.com" + } + ], + "support": { + "issues": "https://github.com/innocraft/plugin-JsTrackerForceAsync/issues", + "source": "https://github.com/innocraft/plugin-JsTrackerForceAsync" + }, + "homepage": "https://www.innocraft.com", + "license": "GPL v3+", + "keywords": ["javascript", "tracker", "async"] +} \ No newline at end of file