Hubs-Foundation / hubs-cloud

Resources for self hosted Hubs Cloud instances
Mozilla Public License 2.0
152 stars 95 forks source link

Built in Google Analytics for HC isn't working. #117

Closed robinkwilson closed 3 years ago

robinkwilson commented 3 years ago

Current behavior Get the google tracker ID and add that to the admin panel does nothing.

Expected Should track enters into rooms.

Linked issues/discussions https://github.com/mozilla/hubs/discussions/3101

robinkwilson commented 3 years ago

Can add these added CSP settings in Server Settings: Admin Panel > Server Settings > Advanced Tab

Merged fix: https://github.com/mozilla/reticulum/pull/420 SEE FILE CHANGES FOR CORRECT CSP SETTINGS for Google Analytics to work. Will be merged into HC soon.

** Working on a better fix with hosting the analytics.js script ourselves: "unsafe-inline" is not the most secure solution.

antpb commented 3 years ago

Hello! I have an event tomorrow and realized I have no tracking set up 😬 . I followed the steps above but it still does not look like it's working. I see in the source this message <!-- NOTE GA tracking is disabled by default. You'll need to set the GA_TRACKING_ID build variable to enable it.

Is this what is blocking it and is there any documentation on enabling that?

antpb commented 3 years ago

I figured it out! It seems after you enter the ID in the admin panel you need to initiate a new deploy from local to build with the ID accounted for 🎉

after a fresh npm run deploy after setting the admin option, things were 100% working and tracking in GA

This may benefit from some documentation in the admin panel. I can make a PR if there is an approach y'all think is best. Could be as simple as a note in the form field.

robinkwilson commented 3 years ago

Oh interesting that you need to deploy again to register the Google ID added. Good to know! Thanks for figuring that out with the custom client.

robinkwilson commented 3 years ago

Should be solved with the new csp settings added to reticulum: https://github.com/mozilla/reticulum/pull/420 You can add these manually if you need to. See file changes.

Dayk0 commented 3 years ago

Hello, I tried the antpb way but it doesn't work. And I'm not sure how to add the file with the CSP rules to my server. Isn't there a way to add script in control panel directly?

williamsullivan commented 3 years ago

This seems broken again with the new Google Analytics version 4 (launched this year), which tracks with Measurement IDs and not UA tags (unless you go to Advanced Settings to get a legacy UA tag). The workaround is to use a UA tag and legacy google analytics, but this should probably be fixed. I think Allowed CORS Origins is also poorly documented (there's no examples of what you would paste in here), only the code changes on Reticulum (which there's no guide for manually updating for Hubs Cloud either). Just about everyone on Hubs Discord I've spoken with has locked themselves out by typing something incorrectly in this field.

antpb commented 3 years ago

@williamsullivan just out of curiosity, would it be possible for you to run a fresh deploy from your local machine to your instance using 'npm run login' and 'npm run deploy'? I had this issue and a fresh deploy magically fixed things.

Vhive2012 commented 1 year ago

Has anyone find a fix for this yet? Our Google Analytics on our Hubs Enterprise Instance running via AWS is tracking but it only tracks the /hub page and not the rooms so we can't see how many people entered a different room.

godunity3d commented 1 year ago

Has anyone find a fix for this yet? Our Google Analytics on our Hubs Enterprise Instance running via AWS is tracking but it only tracks the /hub page and not the rooms so we can't see how many people entered a different room.

Facing same issue. Need solution for this

godunity3d commented 1 year ago

Hello! I have an event tomorrow and realized I have no tracking set up 😬 . I followed the steps above but it still does not look like it's working. I see in the source this message <!-- NOTE GA tracking is disabled by default. You'll need to set the GA_TRACKING_ID build variable to enable it.

Is this what is blocking it and is there any documentation on enabling that?

Please help me How to Enable this : Share solution or code snippet documentation to enable this

Dayk0 commented 1 year ago

Hey ! I managed to fix this problem by deploying a custom server on my cloud hubs. 1) Put your analytics code on your cloud hubs server // 2) Deploy a new cloud hubs server // 3) If you successfully deploy your cloud hubs server, you're done! Follow the instructions to deploy your server: https://hubs.mozilla.com/docs/hubs-cloud-custom-clients.html