@mrjoops opened this Issue on September 22nd 2016

AMP (Accelerated Mobile Pages) sites are gaining traction, and tracking data with this technology is a bit more complicated than with pure HTML/JS: https://www.ampproject.org/docs/reference/extended/amp-analytics.html

Sure we can use the pixel image fallback method for basic tracking, but what about becoming an AMP Analytics vendor ? This would be a great way to promote Piwik at a reasonable cost.


@mattab commented on September 22nd 2016 Member

Thank you @mrjoops for the great suggestion! we will definitely consider it as Piwik needs to be on this list. Google is pushing hard for AMP so this is becoming very important.

If you have knowledge or able to help on this, we would very much welcome your help :+1:

@mrjoops commented on September 23rd 2016

The second link is worth a read, with example pull requests from Xiti and comScore, but I don't have the required Piwik knowledge to answer the questions raised in the document.

@FiloSottile commented on December 8th 2016

There's no need to become a vendor (which probably wouldn't work with self-hosted instances). The JSON specifying the config can be specified by the AMP page (see docs).

<amp-analytics config="https://example.com/analytics.config.json"></amp-analytics>

The PIWIK instance could return a config generated based on the site configuration (like enabling link and timer handlers), and offer a simple snippet like the above for integration in one's AMP site.

In the meantime, an example JSON would also be useful and a valid intermediate iteration.

A more complete implementation would then use the variables to submit all the information in the URL even if custom Javascript can't be run.

@tsteur commented on December 8th 2016 Member

It would be certainly nice to have in Piwik but looking through docs etc would take quite a while. Maybe someone can work out a JSON that could be used and we add later some logic? Also what is the easiest way to test the tracking? Ideally we would also report in the UI whether AMP was used. Something like this might work but I have not tested it:

<script type="application/json">
  "requests": {
    "base": "https://example.com/analytics?a=${account}&u=${canonicalUrl}&t=${title}",
    "pageview": "${base}",
    "event": "${base}&e_c=${eventCategory}&e_n=${eventName}&e_a=${eventAction}"
  "vars": {
    "idsite": "1"
  "triggers": {
    "trackPageview": {
      "on": "visible",
      "request": "pageview"
    "trackAnchorClicks": {
      "on": "click",
      "selector": "a",
      "request": "event",
      "vars": {
        "eventName": "42",
        "eventCategory": "link",
        "eventAction": "click"
@mattab commented on December 15th 2016 Member

There was an article written about AMP and Piwik: http://www.elftronix.com/guide-to-using-piwik-analytics-with-amp-on-wordpress/

@mattab commented on August 7th 2017 Member

If anyone can help adding support for AMP and issuing a pull request, it would be great :+1:

@djallet commented on August 27th 2017

Mixing https://github.com/Automattic/amp-wp and http://www.elftronix.com/guide-to-using-piwik-analytics-with-amp-on-wordpress/ here is a way to use Piwik Pixel without modifying single.php of AMP :

add_action( 'amp_post_template_footer', 'xyz_amp_add_pixel' );
function xyz_amp_add_pixel( $amp_template ) {
    $post_id = $amp_template->get( 'post_id' );
    <amp-pixel src=”//www.myawesomewebsite.com/piwik/piwik.php?idsite=[ID_NUMBER]&rec=1&action_name=TITLE&urlref=DOCUMENT_REFERRER&url=CANONICAL_URL&rand=RANDOM”></amp-pixel>
@mrjoops commented on August 28th 2017

I think some people are missing the point here. As I wrote in my opening post:

Sure we can use the pixel image fallback method for basic tracking, but what about becoming an AMP Analytics vendor ? This would be a great way to promote Piwik at a reasonable cost.

The point isn't only about making Piwik "just" work with AMP, the point is to make it work the good and easy way, and also promoting Piwik.
The pixel method is too limited, you lose too much information.
The @tsteur method may work (not tested) but it's not what I'd call easy.

In my company, AMP are mainly integrated and deployed by programmatically-unskilled people (some marketing-oriented "webmasters"). They can copy/paste a tag, but don't ask them to edit even some JSON. They publish contents on the web without much consideration for the underlying technical stuff.
How many times did I found a corporate web page with a GA tracker in it, while everything in our IT used Piwik, just because they didn't know that Piwik could work with it ? The answer is: way too much.
They are very kind people, they just don't want to know how Internet works, it just have to work. As a developer, my work is to make their lives easier (for better and for worse).
My company isn't alone in this case.

So in the name of those people who think it won't work because it's not listed on https://www.ampproject.org/docs/guides/analytics/analytics-vendors, and because we want Piwik to be used by real people (not only the open-source/privacy nerds), please become an AMP analytics vendor.

@saitho commented on November 14th 2017

@mattab Are there any plans on AMP support for Piwik in the near future?

@mattab commented on November 14th 2017 Member

@saitho @mrjoops Yes, we'd love to support AMP, but we're lacking resources at the moment. Would anyone be willing to help and lead this effort? we can provide support but can't lead it ourselves at the moment. Thanks

@mrjoops commented on November 15th 2017

I could probably take a deeper look at this, read all the docs and vendor submission procedures, elaborate on a plan and maybe hack a little before the end of the year, if it could help.

@sgiehl commented on November 15th 2017 Member

@mrjoops would be awesome if you could handle that. If you have any questions we can help with, feel free to ask :)

@ullahfahad commented on March 27th 2019

Did any progress happen on this front? I am in the boat of integrating Matomo now and 30% of my traffic out of 2.0million monthly sessions comes from AMP pages.

@tsteur commented on March 27th 2019 Member

We haven't worked on this ourselves but we'd provide any help if someone is keen to make progress on this.

@mattab commented on June 5th 2019 Member

FYI there was a post in the forums which possibly includes a solution: https://forum.matomo.org/t/how-to-add-piwik-to-amp-pages/18424/6

@mattab commented on February 26th 2020 Member
@mattab commented on March 2nd 2020 Member

What would be the effort to build AMP support for Matomo?

@dannyeuu commented on November 9th 2020

@mattab Any updates here?

@atom-box commented on March 7th 2022

A user wrote, asking if Amp HTML is compatible with Matomo.

He sent a link of which of our peers are used with Amp:

I see several of the tags are different:

Powered by GitHub Issue Mirror