ga-lite icon indicating copy to clipboard operation
ga-lite copied to clipboard

Customizable endpoint URL and User Language

Open kidonng opened this issue 2 years ago • 2 comments

I noticed some parameters are hard-coded, specifically, the Google Analytics endpoint URL (https://www.google-analytics.com/collect) and User Language (ul):

https://github.com/jehna/ga-lite/blob/6b467e592b9880d9f8eb270f20c57e74176b3c6c/src/get-base-url.js#L5-L7

It would be awesome to be able to:

  • Make ul use actual language provided by the user agent (e.g. navigator.language)
  • Use a custom endpoint URL to avoid people blocking the official endpoint

kidonng avatar Feb 27 '22 05:02 kidonng

Thank you for opening the issue. Good catch on the ul parameter! This should now be fixeed with #462

Using a custom endpoint would make sense — it would allow for routing the requests from your own domain (getting around any third-party restrictions), and even creating an alternative backends for the ga protocol.

How would you like to pass the endpoint url to ga-lite? How about something like:

galite('create', 'UA-XXXXXXXX-X', 'auto');
galite('set-endpoint', '/my-custom-collect-endpoint');
galite('send', 'pageview');

jehna avatar Mar 08 '22 21:03 jehna

This would be majorly useful. Looking at using this script to proxy traffic through a cloudflare worker.

nickreese avatar Mar 12 '22 11:03 nickreese