Git Product home page Git Product logo

jekyll-analytics's Introduction

Build Status Maintainability

Jekyll::analytics

Webanalytics for Jekyll.

There are many tutorials online to add analytics to Jekyll by extending the template. Jekyll-analytics is here to take care of this. Just install the plugin, configure it and you are done :)

Jekyll-analytics: Webanalytics made easy.

Supported:

Installation

Add this to your Gemfile:

gem 'jekyll-analytics'

Then execute

$ bundle

Or install it yourself

gem install jekyll-analytics

Configuration

Edit _config.yml to use the plugin:

plugins:
  - jekyll-analytics

Configure the plugin in _config.yml by adding:

jekyll_analytics:
  GoogleAnalytics:          # Add, if you want to track with Google Analytics
    id: UA-123-456          # Required - replace with your tracking id
    anonymizeIp: false      # Optional - Default: false - set to true for anonymized tracking

  Matomo:                   # Add, if you want to track with Matomo (former Piwik Analytics)
    url: matomo.example.com # Required - url to Matomo installation without trailing /
    siteId: "1234"          # Required - replace with your Matomo site id (Write id as string)

  Piwik:                    # Add, if you want to track with Piwik
    url: piwik.example.com  # Required - url to Piwik installation without trailing /
    siteId: "1234"          # Required - replace with your Piwik site id (Write id as string)

  MPulse:                   # Add if you want to track performance with mPulse
    apikey: XXXXX-YYYYY-ZZZZZ-AAAAA-23456   # Required - replace with your mPulse API key

  Plausible:
    domain: 'example.com'   # The domain configured in plausible
    source: 'https://plausible.example.com/js/plausible.js' # The source of the javascript

Usage

Tracking will be disabled in development mode. To enable production mode set enviroment variable JEKYLL_ENV=production. Github pages automatically sets JEKYLL_ENV to production. For testing use

$ JEKYLL_ENV=production jekyll serve

Contributing

  1. Fork it ( https://github.com/hendrikschneider/jekyll-analytics/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

How to add support for a new tracker:

  1. Create new tracker class in lib/analytics/YourTracker.rb
#initialize and render must be implemented!
class YourTracker
  def initialize(config)
    #validate config
  end

  def render
    return "Tracking code to insert into html > head"
  end
end
  1. Update README.md

jekyll-analytics's People

Contributors

barde avatar bluesmoon avatar clayrisser avatar davids avatar dependabot-preview[bot] avatar gabrielepmattia avatar hendrik91 avatar hendrikschneider avatar jayvdb avatar mardy avatar pascalbru avatar supersandro2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jekyll-analytics's Issues

Syntax error

Hi, I just added jekyll-analytics to my site but when I run jekyll serve I get this:

$ jekyll s
/home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/jekyll-analytics.rb:1:in `require': /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/analytics/Matomo.rb:4: syntax error, unexpected tIDENTIFIER, expecting keyword_end (SyntaxError)
    <script type="text/javascript">
                      ^
/home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/analytics/Matomo.rb:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
<script type="text/javascript">
                              ^
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/jekyll-analytics.rb:1:in `block in <top (required)>'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/jekyll-analytics.rb:1:in `each'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-analytics-0.1.7/lib/jekyll-analytics.rb:1:in `<top (required)>'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `require'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `each'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `block in require'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `each'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `require'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.4/lib/bundler.rb:108:in `require'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/lib/jekyll/plugin_manager.rb:51:in `require_from_bundler'
	from /home/mardy/.rvm/gems/ruby-2.4.0/gems/jekyll-3.6.2/exe/jekyll:11:in `<top (required)>'
	from /home/mardy/.rvm/gems/ruby-2.4.0/bin/jekyll:22:in `load'
	from /home/mardy/.rvm/gems/ruby-2.4.0/bin/jekyll:22:in `<main>'
	from /home/mardy/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
	from /home/mardy/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'

Firebase support

Hi,

As far as I know Google Analytics is now embedded on Firebase and an Firebase app is mandatory to have a Google Analytics app configuration (am I wrong?).

I then created a new app on Firebase and created a Google Analytics app for my website.

Despite this sound correct I noticed that when I search for the GoogleAnalytics tracking id now is no longer in the form "UA-123-456".

Can I use the new Firebase ID and settings in this plugin? Does the plugin supports the new Firebase settings?

Thank in advance for your help.

Plugin is not activated on GitHub Pages

It seems that GitHub pages no longer sets JEKYLL_ENV. I tried it locally and your plugin works just fine, but when built by GitHub pages, analytics are disabled. Can you reproduce this problem or do you know a workaround?

Ask for comment, facebook pixel

Besides google analytics, I like to have a plugin for facebook pixel.
just the basic feature of facebook pixel.

I am waiting for your input, also want some guidance to extend the current functionality, I am not a ruby developer tho.

Thanks

No analytics code is added to html pages

I'm trying to add Plausible analytics to my GitHub pages site. I assume that when everything works, the following snippet should be added somewhere between the <head> tags:

<script async defer data-domain="roald87.github.io" src="https://plausible.io/js/plausible.js"></script>

I did the following:

  1. Added gem 'jekyll-analytics' to my Gemfile
  2. Did bundle install, where I see the following line in the output: Using jekyll-analytics 0.1.14
  3. Added the following to my _config.yml file:
    plugins:
      - jekyll-analytics
    whitelist: [jekyll-analytics]
    
    Plausible:
      domain: 'roald87.github.io'   # The domain configured in plausible
      source: 'https://plausible.io/js/plausible.js' # The source of the javascript
    
  4. Did bundle exec jekyll serve JEKYLL_ENV=production

When I inspect the index.html no analytics tag is added in the head. I also tested it with the GoogleAnalytics one, by replacing the Plausible: ... with:

GoogleAnalytics:          # Add, if you want to track with Google Analytics
    id: UA-123-456          # Required - replace with your tracking id
    anonymizeIp: true      # Optional - Default: false - set to true for anonymized tracking

But again with the same result.

When I check the verbose output of jekyll serve I do no see the jekyll-analytics module being used anywhere:

$ bundle exec jekyll serve --verbose JEKYLL_ENV=production | grep "Requiring"
         Requiring: jekyll-github-metadata
         Requiring: jekyll-seo-tag
         Requiring: jekyll-feed
         Requiring: jemoji
         Requiring: jekyll-coffeescript
         Requiring: jekyll-commonmark-ghpages
         Requiring: jekyll-gist
         Requiring: jekyll-github-metadata
         Requiring: jekyll-paginate
         Requiring: jekyll-relative-links
         Requiring: jekyll-optional-front-matter
         Requiring: jekyll-readme-index
         Requiring: jekyll-default-layout
         Requiring: jekyll-titles-from-headings
         Requiring: jekyll-remote-theme
         Requiring: jekyll-seo-tag
         Requiring: kramdown-parser-gfm
/home/roald/gems/gems/pathutil-0.16.2/lib/pathutil.rb:502: warning: Using the last argument as keyword parameters is deprecated
         Requiring: jekyll-watch

Or doesn't it show up in here?

Am I doing something wrong here?

Matomo Image Tracker not loading

I am using this plugin to get my self-hosted matomo to be included.
What doesn't work at the moment is the Matomo Image Tracker that is automatically included. As I have defined my personal url in the _config.yml it seems that the generated html is missing the protocol definition: http:// or https://
Currently it is requesting;
<img src="matomo.foobar.com?idsite=1&amp;rec=1" style="border:0" alt="">
but that results in an image not found, both in inspector as in the actual rendered webpage.

Plugin showing extra text

Plugin configured in Gemfile:
...
gem 'jekyll-analytics', '~> 0.1.11'
...

and added in _config.yml
...
plugins:
- jekyll-feed
- jekyll-sitemap
- jekyll-paginate
- jekyll-seo-tag
- jekyll-analytics

jekyll_analytics:
GoogleAnalytics: # Add, if you want to track with Google Analytics
id: UA-XXXX-XX # Real id is in place
anonymizeIp: false # Optional - Default: false - set to true for anonymized tracking
...

running via JEKYLL_ENV=production bundle exec jekyll serve
and I can see this text at the top of the page

closing tag, Google Analytics can be placed here -->

looking at the source of the page, I see:

    <!-- This goes before 
    <!-- Google Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-811002-18', 'auto');
  ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});
  ga('set', 'anonymizeIp', false);
    </script>
    <!-- End Google Analytics -->
    </head> closing tag, Google Analytics can be placed here --> 



    <!-- Google Analytics -->

Piwik has been renamed to Matomo

As announced a couple of days ago Piwik is being rebranded to Matomo. Would it be possible to get the ability to use either the Piwik configuration key or the Matomo key? This will help with backwards compatibility, as well as allowing future users to be able to not have the confusion about Piwik vs Matomo

Error: undefined method `keys' for nil:NilClass

Occurs if there is not an array at jekyll-analytics:.

Sometimes the plugin needs to be installed, but isnt operational, such as on a UAT environment where lots of testing is done before deployment to production.

Analytics is not injected in collections other than posts

Hey there,

The analytics plugin currently injects analytics headers in pages and posts, but any other type of user-defined collection will not be considered. This results in non-posts collections to be not included in analytics.

Consider injecting analytics headers in any type of collection, instead of only posts.

Thank you!

matomo-url needs ending slash

When configuring matomo-url like this:

  Matomo:                   
    url: matomo.example.com 
    siteId: "1234"         

then the url will look like this:

https://matomo.example.compiwik.php/?action_name=....

The / is missing between url and piwik.php.
That's what in the generated page:

...
      (function() {
        var u='//'+"matomo.example.com";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', '2']);
...

It should contain the slash:

...
  (function() {
    var u="//matomo.example.com/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '2']);
...

Uninitialized constant Module::Plausible

Hello!

I installed jekyll-analytics in the version 0.1.14. I followed the readme in order to set up Plausible analytics, but when I tried to build the page I encountered an error:

/usr/local/bundle/gems/jekyll-analytics-0.1.14/lib/jekyll-analytics.rb:8:in `block in inject': uninitialized constant Module::Plausible (NameError)
	from /usr/local/bundle/gems/jekyll-analytics-0.1.14/lib/jekyll-analytics.rb:7:in `each'
	from /usr/local/bundle/gems/jekyll-analytics-0.1.14/lib/jekyll-analytics.rb:7:in `inject'
	from /usr/local/bundle/gems/jekyll-analytics-0.1.14/lib/jekyll-analytics.rb:21:in `block in <top (required)>'

If I understand it correctly, it looks like the latest released version is from June, but the change which introduced Plausible is from October.

Could you please make an release? :)
What do you think about auto releasing on merge to master? Could I help with it?

Using the plugin for plausible

Used this issue to attempt to make it work, because it didn't work when I followed the main README.md guide

I can see Plausible present in the Console developer view for my site (ebristow.com), but when I reload the page it doesn't show up under Network so it doesn't look like it's reaching out to Plausible. Any help is appreciated - thank you!

In _config.yml:

plugins:
  - jekyll-feed
  - jekyll-target-blank
  - jekyll-analytics

jekyll_analytics:
  Plausible:
    domain: 'ebristow.com'   # The domain configured in plausible
    source: 'https://plausible.io/js/plausible.js' # The source of the javascript

In Gemfile:
group :jekyll_plugins do gem "jekyll-feed", "~> 0.12" gem "jekyll-analytics", "~> 0.1", git: 'https://github.com/hendrikschneider/jekyll-analytics', ref: '40e09570dea80e3a9ecb0ad796aad1c434ff067c' # https://github.com/hendrikschneider/jekyll-analytics end

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.