kadirahq / meteor-dochead

Isomorphic way to manipulate document.head for Meteor apps
MIT License
132 stars 17 forks source link

Where should i add DocHead.loadScript? #23

Open Mindgames opened 8 years ago

Mindgames commented 8 years ago

Trying to add DocHead.loadScript but can't get it to work. Could you please tell me where and how to add this in a Flowrouter-srr stack

var gaScript = 'https://www.google-analytics.com/analytics.js';
DocHead.loadScript(gaScript, function() {
    // Google Analytics loaded
    ga('create', 'UA-XXXX-Y', 'auto');
    ga('send', 'pageview');
});

Made a good effort myself to get it to work. Asked on Meteor forum, Stackoverflow, Tons of Google & and even searched through all github repos after some repo that used it in it's code, But nothing...

Putting up good examples would make the biggest difference, saving time for both users and on your part eliminating loads of questions.

SachaG commented 8 years ago

I don't think it matters where you add it. But as far as I can tell, this only works on the client, meaning it will not be SSR'd. I might be wrong though.