Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSean Pierce Sumler
18,968 Pointslinking to Google analytics from a script src
Just curious-
Let's say I don't want to clutter or see the google analytics script code that I was provided to nest in my website. Could I place the code into a file named js/analytics.js, then link that to my page using a script tag in my HTML markup?
Is this bad practice, or totally acceptable?
Thanks in advance, Sean
2 Answers
michelle levine
12,616 PointsWith the way the newer Google Analytics code works, it won't actually work correctly if you put it into an external sheet and call it in. I know it isn't pretty, but in this case, it is definitely best to listen to Google and put it at the end of the <head></head> block like they recommend.
Sean Pierce Sumler
18,968 PointsI figured that was the case because I kept receiving console errors. I just wanted to double check with the community here. Thanks Michelle!