Reputation: 2388
I built a site with python dash app and now I want to insert Google Analytics. The google javascript looks like this:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');
</script>
What I've tried so far:
app.scripts.append_script({‘external_url’:‘https://mywebsite.com/assets/gtag.js’})
Put Google Analytics script under /assets
None of these seem to work, since I don't see any updates in the Google Analytics dashboard.
Should I put the script before the HTML head in dash app? How could I do this?
Upvotes: 2
Views: 2146
Reputation: 2388
This is solved now.
I should remove the 'script' in the js file, then put it in assets fold, everything is working right now.
Upvotes: 3