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

Disable analytics in development #1359

Closed
1 of 5 tasks
maazadeeb opened this issue Nov 19, 2017 · 4 comments
Closed
1 of 5 tasks

Disable analytics in development #1359

maazadeeb opened this issue Nov 19, 2017 · 4 comments

Comments

@maazadeeb
Copy link
Contributor

maazadeeb commented Nov 19, 2017

  • This is a question about using the theme.
  • This is a feature request.
  • I believe this to be a bug with the theme.
    • I have updated all gems with bundle update.
    • I have tested locally with bundle exec jekyll build.

Environment informations

  • Minimal Mistakes version: 4.7.1
  • Jekyll version: 3.5.2
  • GitHub Pages hosted: yes
  • Operating system: macOS 10.10.5

Expected behavior

I realised that my blog's page visits were being tracked even in development. This is adding wrong entries into the site analytics. I would expect that the theme has a way to disable analytics in development.

Just to solve the issue quickly, I added if (window.location.hostname !== "localhost") { ... } in google-universal.html.

But, after searching a bit, I found that we can use

{% if jekyll.environment == 'production' %}
  I'm in production!
{% else %} 
  I'm in development!
{% endif %}

I would add this change in analytics.html.

If you think this is a valid feature request, I wouldn't mind submitting a PR for this.

@maazadeeb
Copy link
Contributor Author

This could apply to the comments section as well.

@mmistakes
Copy link
Owner

@maaz93 This sounds like a good idea to me if you want to go ahead and submit a PR. Maybe do them as two separate PRs... one for disabling Google Analytics in nonprod and another for disabling comments.

You can probably piggyback on these lines

_includes/analytics.html

{% if jekyll.environment == 'production' and site.analytics.provider and page.analytics != false %}

_layouts/single.html

{% if jekyll.environment == 'production' and site.comments.provider and page.comments %}

@maazadeeb
Copy link
Contributor Author

@mmistakes Sounds good! Should I create a separate issue for disabling the comments or can I use this issue itself for both PRs?

@mmistakes
Copy link
Owner

You can reference this same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants