-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
How to use the code #1
Comments
@carerragt Hi there, Thanks for reaching out 👍 Given you're using Hugo to build your site, it's now occurred to me that we don't have an easy way for users like yourself (who are not using a JavaScript based build tool) to include the script on a page. Currently, the instructions assume a Node environment. I've just pushed a new version that remedies this. In the You'll find the built script at the link below: You can either include it on the page as is, or self host it. Once included, you'll need to define two properties on the window, A full example is below: <script src="https://unpkg.com/@minimal-analytics/ga4/dist/index.js" async />
<script>
window.minimalAnalytics = {
trackingId: 'GX-XXXXX', // <-- replace with your GA4 property ID
autoTrack: true,
};
</script> Let me know how you get on. Thanks for contributing! |
It is working now! Thanks a lot. Let me leave it running for a few days and see. |
Hi. It has been working well and I like it! Just getting significant amount of "unassigned" traffic which I think is a limitation of GA4. Thanks again and cheers! |
Hey @carerragt, Great, glad it's working out well 👍 |
I'm using Eleventy, which is a static site generator like Hugo, but based on Node. I didn't want to depend on an external CDN (unpkg) and I didn't want to manually copy the script into my app, because I wanted it to stay current. So I used the following code to copy from the node module at build time. This goes in
You would just change Then in the head tag of my template, I used the following tag:
Thanks for all your great work, @jahilldev! |
Hi there @marshmallowcreme, Thanks for sharing your implementation! I'm actually using 11ty with this library too, but in a slightly different way. If you're using a JavaScript build tool for your client side code, including the script is as simple as doing this: import { track } from '@minimal-analytics/ga4';
track('GX-XXXXXX'); // or define on window Thanks again for sharing, great example 👍 |
@jahilldev Thank you. I will do that if and when I decide to add a JS build tool. |
I am sorry to re-open this issue, but I tried to implement the simplest solution for me, by adding just the following lines to my pages' head:
But I get now hits. Of course, I have replaced the 'G-XXXXX' with my GA4 property ID. Is there anything else I need to add? |
Thank you James! I'll be seeing you there... |
Hi. I installed node.js and run the command you provided.
The text was updated successfully, but these errors were encountered: