fastboot-app-server
fastboot-app-server copied to clipboard
script tag in index.html
Hi,
we are in the process of enabling our ember app for fastboot. So far it works very well when using ember serve
, but it's not yet working with fastboot-app-server: We have a script tag in our index.html to load google analytics as suggested from google at https://developers.google.com/analytics/devguides/collection/analyticsjs/
<!-- Google Analytics -->
<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-XXXXX-Y', 'auto');
</script>
<!-- End Google Analytics -->
When using ember server
we can then later on access the ga object as window.ga
but when accessing the page via fastboot-app-server, this results in TypeError: window.ga is not a function
. Can you help me fix this or just indicate where I missed something in the docs? I would be very grateful for your help!
Any updates/work-around for this?
In general you need to worry about accessing window on node in a running app will error. One option is to block the ga function call if window is not present