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

Fix google analytics feature #989

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joyao
Copy link
Member

@joyao joyao commented Oct 1, 2024

Issue

Fixes #955

Description

Fix google analytics feature based on official document.
https://gohugo.io/templates/embedded/#google-analytics

Test Evidence

image

Copy link

netlify bot commented Oct 1, 2024

Deploy Preview for toha-ci ready!

Name Link
🔨 Latest commit 86fe513
🔍 Latest deploy log https://app.netlify.com/sites/toha-ci/deploys/6716769b2e37270008c30c99
😎 Deploy Preview https://deploy-preview-989--toha-ci.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@BernatBC BernatBC added the bug-fix Bug fixes label Oct 2, 2024
Copy link
Member

@hossainemruz hossainemruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @joyao ! Thank you for the PR. Look like we are breaking compatibility here. With this change, following configuration will not work anymore:

services:
  googleAnalytics:
    ID: G-MEASUREMENT_ID

Do we want to force user to use analytics configuration from site.Params.analytics.services.google.id ? In that case, we should also provide a way do specify respectDoNotTrack under site.Params.analytics.services.google section.

@joyao
Copy link
Member Author

joyao commented Oct 18, 2024

Hi @joyao ! Thank you for the PR. Look like we are breaking compatibility here. With this change, following configuration will not work anymore:

services:
  googleAnalytics:
    ID: G-MEASUREMENT_ID

Do we want to force user to use analytics configuration from site.Params.analytics.services.google.id ? In that case, we should also provide a way do specify respectDoNotTrack under site.Params.analytics.services.google section.

I think both methods should be supported. I’ll fix it and thanks for your suggestion.

@joyao
Copy link
Member Author

joyao commented Oct 21, 2024

Hi @hossainemruz, under the "{{ with .google }}" condition, my original changes support both project custom settings and original settings as following, and have been tested.

analytics:
  enabled: true
  services:
    # Google Analytics
    google:
      id: G-H4LBG7NDFZ
      respectDoNotTrack: false
services:
  googleAnalytics:
    ID: G-H4LBG7NDFZ
privacy:
  googleAnalytics:
    disable: false
    respectDoNotTrack: true

So I just add the "respectDoNotTrack" part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug Google Analytics has stopped working
3 participants