Giter VIP home page Giter VIP logo

Comments (3)

kungfux avatar kungfux commented on May 27, 2024 1

I was happy to help @sukhjinder-kumar

is there something we can do so that Adblocker doesn't block the request?

I don't think so. If user decided to protect his privacy and so Adblock extension prevents to send requests to analytics, there is no way to bypass easily, I guess.

Please check additional info available in GoatCounter's FAQ regarding this problem as there are options described.

from jekyll-theme-chirpy.

kungfux avatar kungfux commented on May 27, 2024

@sukhjinder-kumar I have implemented views counter recently using GoatCounter, here what I have done.

  • I have copied original _layouts/post.html to my project, so I can override it to add views counter where I want it to be
      <span>
        {% include views.html tooltip=true lang=lang %}
        {{ site.data.locales[lang].post.pageview_measure }}
      </span>
  • Created a new file _includes/views.html to have views counter logic
<!-- Views Counter -->

<script>
  const r = new XMLHttpRequest();
  r.addEventListener('load', function() {
      document.querySelector('#views').innerText = JSON.parse(this.responseText).count
  });
  const uri = location.pathname.replace(/\/$/, "");
  r.open('GET', 'https://{{ site.goatcounter.id }}.goatcounter.com/counter/' + encodeURIComponent(uri) + '.json');
  r.send();
</script>

<span>
  <em id="views"></em>
</span>

The JS code is taken from GoatCounter site https://www.goatcounter.com/help/visitor-counter#json-851
That's about it. I hope this helps you get what you want while waiting for the changes in the theme.

image

P.S. Error fetching Json may be expected when there are no data for page visits in GoatCounter yet.

from jekyll-theme-chirpy.

sukhjinder-kumar avatar sukhjinder-kumar commented on May 27, 2024

Thank you for taking your time and helping me out. This solves my issue. Just to be sure, is there something we can do so that Adblocker doesn't block the request? I saw it on your github.io too, ublock is blocking the request (works in incognito).

from jekyll-theme-chirpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.