Include global JS script with env/config variables

Hey all, I'm trying to create an addon that adds a JS snippet to every page - (actually I'd need it only on collection editing page) - and that can read from an env variable or config value.

For example, imagine including the Google Analytics tracking code. You'll need something like this:

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');

In the second-last LoC a token is required (UA-XXXXX-Y) and you would place that inside an env variable (and a config value), but how can you read that value from a JS file?

I've read that you could add it as a MIX variable, but that would require the user installing the Addon to rebuild the assets both in local and production.

Thank you!

>>>>>>> Unanswered <<<<<<<
0 Replies