Open bradipao opened 3 years ago
In #30, we are introducing a new include for custom headers. I'd propose that we put this old code there (for backwards compatibility) and then allow folks who want to use v4 to put that custom data into a custom include for Google Analytics.
To be clearer:
_layouts/default.html
contains {% include head-custom.html %}
or similar._includes/head-custom.html
(maybe make it underscore-delimited) includes {% include google_analytics.html %}
_includes/google_analytics.html
contains pre-existing v3 code. User replaces this include inside their site with the code they want to be included instead.This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Thank you! It would be great if you could add some information to the main page. I installed GA4, and only then realized that I need the other tracking number.
I tried to enable Google Analytics using the proper parameter (google_analytics) in _config.yml and the intended code is actually injected in the page, but apparently it is valid only for old Analytics tracking IDs (UA-xxxxxxx). New measurement IDs (G-xxxxxxxx) seems to need a different script code.
I modified _default.html removing current code and I added new code just after HEAD tag as per Google Analytics documentation ( https://developers.google.com/analytics/devguides/collection/gtagjs ). After a few try it seems working now.
It is still compatible with the "google_analytics" parameter in _config.yml, the difference is just in the script code. But in a more general approach probably a dedicated parameter would be better, to have both scripts in the layout.