Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document adding Custom JS to tracker via tracker.js / tracker.min.js on https://developer.matomo.org/guides/enrich-js-tracker #11572

Closed
loki495 opened this issue Mar 31, 2017 · 7 comments · Fixed by matomo-org/developer-documentation#345
Assignees
Labels
c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Website matomo.org For issues related to our matomo.org website.
Milestone

Comments

@loki495
Copy link

loki495 commented Mar 31, 2017

Is there a way for a plugin to add custom JS to tracker response and have the piwik.js parse/execute it?
https://forum.piwik.org/t/returning-json-jsonp-from-tracker/23657

@tsteur
Copy link
Member

tsteur commented Apr 1, 2017

It is technically possible but as @mattab mentioned there are no docs which actually is missing because it is not really a public API and neither supported right now. Basically you can create a tracker.js file or tracker.min.js file in your plugin and it will be copied into the piwik.js

@mattab mattab changed the title Adding Custom JS to tracker Document adding Custom JS to tracker via tracker.js / tracker.min.js May 8, 2017
@mattab mattab added this to the Backlog (Help wanted) milestone May 8, 2017
@mattab mattab added the c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. label May 8, 2017
@mattab mattab added the c: Website matomo.org For issues related to our matomo.org website. label Jun 21, 2017
@mattab
Copy link
Member

mattab commented Jun 21, 2017

@tsteur maybe we could make this public API in Piwik 4? (moving tentatively)

@mattab mattab modified the milestones: 4.0.0, Backlog (Help wanted) Jun 21, 2017
@tsteur
Copy link
Member

tsteur commented Jun 22, 2017

could maybe make it but maybe lets see again when we get to it. Would require a bit more work and especially documentation. Not having a big opinion on it but would need to think more about it also for long term how this should work

@johsin18
Copy link
Contributor

Let's document that this "API" exists, first of all. I used this interface also for my plugin for #11405 after trying hard with custom variables, setCustomTrackingParameter (not available for JS tracker) and so on... it was quite a pain.

@mattab mattab added the c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. label Feb 20, 2020
@johsin18
Copy link
Contributor

johsin18 commented Apr 1, 2020

What is also undocumented is that the plugin class needs to override the method isTrackerPlugin like so

public function isTrackerPlugin()                                                                      
{                                                                                                      
    // declare that this plugin's tracker(.min).js should be included in the JavaScript tracker code   
    return true;                                                                                       
}                                                                                                      

My plugin broke with Matomo 3.13 due to lacking this code, I had to make a bugfix release.
https://plugins.matomo.org/DevicePixelRatio/changelog

@tsteur
Copy link
Member

tsteur commented May 14, 2020

@johsin18 fixed the isTrackerPlugin regression in #15954 and documented the tracker in matomo-org/developer-documentation#345 which now only needs a review.

@tsteur
Copy link
Member

tsteur commented May 17, 2020

@loki495 things are now documented in https://developer.matomo.org/guides/enrich-js-tracker

@mattab mattab changed the title Document adding Custom JS to tracker via tracker.js / tracker.min.js Document adding Custom JS to tracker via tracker.js / tracker.min.js on https://developer.matomo.org/guides/enrich-js-tracker Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. c: Website matomo.org For issues related to our matomo.org website.
Projects
None yet
4 participants