• Resolved Sohail Ahmed

    (@indiaatnet)


    Hello,

    Is this plugin able to track Visits on AMP version of website? Our mobile view is only AMP using the default amp plugin.

    • This topic was modified 9 months, 2 weeks ago by Sohail Ahmed.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @indiaatnet,

    Unfortunately the answer is no. AMP doesn’t allow third-party scripts to run on page load. Anything that relies on JavaScript (such as WordPress Popular Posts) will not work.

    Thread Starter Sohail Ahmed

    (@indiaatnet)

    Jetpack claims to record amp visits..

    anyways, I do have access to inject any JS code into the amp page. Can you guide me on what has to be injected in order to count the visits?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Jetpack claims to record amp visits..

    Oh, I guess Jetpack must be using amp-script to do so? I wasn’t aware that AMP allows third party code now, it wasn’t that way the last time I checked so that’s good news (Google launched amp-script by the end of 2019 and thanks to you I just found that out.)

    anyways, I do have access to inject any JS code into the amp page. Can you guide me on what has to be injected in order to count the visits?

    I’m not really familiar with AMP nor amp-script yet so this might or might not help: How To – Updating Views Count via AJAX.

    Thread Starter Sohail Ahmed

    (@indiaatnet)

    So any plans to add this feature anytime soon now?

    Thread Starter Sohail Ahmed

    (@indiaatnet)

    I have manually added the wpp.min.js code to AMP version using:

    <script data-ampdevmode type="text/javascript" src="https://www.xxxxx.com/wp-content/plugins/wordpress-popular-posts/assets/js/wpp.min.js?ver=6.4.0" id="wpp-js-js"></script>

    Its now recording the visits but its giving the following error in console log: https://pasteboard.co/BBwHdfo0vi08.png

    Plugin Author Hector Cabrera

    (@hcabrera)

    So any plans to add this feature anytime soon now?

    No plans at the moment. I would need to familiarize myself with AMP in general first to gauge how much work is involved and whether it’s worth it or not: according to W3Techs only around 0.3% of all the websites out there are using AMP, at the time of writing at least; plus there’s the fact that AMP is a Google product, and Google isn’t exactly known for keeping most of their products around for long.

    I have manually added the wpp.min.js code to AMP (…)

    Its now recording the visits but its giving the following error (…)

    Then it’s not recording visits. The error you’re seeing means that wpp.min.js cannot find some specific variables -the “JSON” data- printed onto the page via an inline script tag. Said inline script tag variables are dynamic, their values are set via PHP on page load. If you plan to continue using wpp.min.js then you’ll need to figure out how to mimic that as well.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Amp visits count’ is closed to new replies.