jazzband/django-analytical

Support for Google Analytics 4 tags

carlosnasillo opened this issue · 9 comments

Any new Google Analytics account is not able to create the previous 'universal' properties (UA-XXXXXX-Y, AW-XXXXXXXXXX, UA-XXXXXX-X, DC-XXXXXXXX) and instead now the tracking IDs look like (G-XXXXXXXXXX).

https://blog.google/products/marketingplatform/analytics/new_google_analytics
https://support.google.com/analytics/answer/10089681

As a result Django-analytical does no longer support for any of the new google analytics integrations.

Thanks, Carlos, for reporting this problem.

Can you suggest a specific change? Do you want to try a PR?

Hi, I hope to solve this problem.
but i am new to git contribution.
can you help me to solve it?

@likecodeingloveproblems It's good to hear that! Contributors are the best people around!

It's actually simple, as for the code change:

  1. You'd have to adjust the regular expression in templatetags/google_analytics_gtag.py, so that it allows the patterns @carlosnasillo listed above.
  2. And, of course, also align the related tests.

The test suite should then pass. Try running tox locally. It should all be green. Then you're ready to push your changes and open a pull request.

Mastering GitHub

If you've never made a contribution on GitHub (or GitLab or Bitbucket, and the like) there are a few things you need to learn, but the good news is there are also loads of nice tutorials that explain how to do it, e.g.

Go forward, step by step! Come back here to ask for help if needed! 🚀 👍 💯

thanks
you are really kind

1.You'd have to adjust the regular expression in templatetags/google_analytics_gtag.py, so that it allows the patterns @carlosnasillo listed above.
it is already adjusted to regular expression "^G-[a-zA-Z0-9]+$"

2.And, of course, also align the related tests.
and all test by running tox passed

@carlosnasillo Can you clarify your statement?

As a result Django-analytical does no longer support for any of the new google analytics integrations.

A G-XXXX... ID seems to be accepted by django-analytical, see PROPERTY_ID_RE in google_analytics_gtag.py.

@bittner @likecodeingloveproblems

tldr: the issue might be with google_analytics_js.py instead of google_analytics_gtag.py

Back when I was updating my GA tag from G3 (ie. UA-XXXXXX-Y) to the new G4 (G-XXXXXXXXXX) it was not being parsed as correct when assigned to GOOGLE_ANALYTICS_JS_PROPERTY_ID in Django settings.py

See the PROPERTY_ID_RE within google_analytics_js.py

I hope this helps.

Has this issue been resolved? I will like to contribute to this if it is still open.

If I'm not mistaken this issue is still unsolved. Feel free to open a PR.

Alright. I'll work on this