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

No analytics code is added to html pages #53

Closed
Roald87 opened this issue Jan 2, 2021 · 5 comments
Closed

No analytics code is added to html pages #53

Roald87 opened this issue Jan 2, 2021 · 5 comments

Comments

@Roald87
Copy link

Roald87 commented Jan 2, 2021

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?

@Roald87
Copy link
Author

Roald87 commented Jan 3, 2021

My solution was to fork the jekyll theme repo and hard code the Plausible snippet in there Roald87/texture@85a1820.

@dotZak
Copy link

dotZak commented Mar 30, 2021

@Roald87 The environment variable needs to be set before Jekyll runs, right now you're setting it too late.

See:

# correct:
JEKYLL_ENV=production bundle exec jekyll serve

# incorrect:
bundle exec jekyll serve JEKYLL_ENV=production

@Roald87
Copy link
Author

Roald87 commented Apr 2, 2021

Thanks will try it!

@dotZak
Copy link

dotZak commented Apr 7, 2021

@Roald87 It's been a few days. Can you confirm if that solved your issue?

@Roald87
Copy link
Author

Roald87 commented Apr 8, 2021

🤷 it still doesn't work.

Never mind then. I'm OK with the work-around.

@Roald87 Roald87 closed this as completed Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants