tag:blogger.com,1999:blog-2194307155784714841.post5861021484031362379..comments2024-03-13T13:18:01.283+01:00Comments on Ronnie H. Hegelund: Declaration source files and google analyticsAnonymoushttp://www.blogger.com/profile/05784212143757034903noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-2194307155784714841.post-87195059345662746562013-09-06T22:04:55.385+02:002013-09-06T22:04:55.385+02:00Nevermind. I got around to playing with this agai...Nevermind. I got around to playing with this again immediately realized I was referencing the newer "Universal Analytics" script instead of the old ga.js. Changing the referenced script fixed the problem.Eric Burchamhttps://www.blogger.com/profile/01871133830095696088noreply@blogger.comtag:blogger.com,1999:blog-2194307155784714841.post-13103217993992597972013-08-15T04:52:31.956+02:002013-08-15T04:52:31.956+02:00Still embarrassed. Still can't get a simple p...Still embarrassed. Still can't get a simple page view to track, though I can confirm extending Node fixed the original compilation problem.<br /><br />Here is my current .ts file contents:<br />ga = document.createElement("script");<br />ga.async = true;<br />ga.src = '//www.google-analytics.com/analytics.js';<br />ga.type = 'text/javascript';<br />document.body.appendChild(ga);<br /><br />var tracker = _gat._createTracker('UA-XXXXXX-1', 'mydomain.com');<br />tracker._trackPageview();<br /><br />Now the exception I get is: "JavaScript runtime error: '_gat' is undefined."<br /><br />Like I said, I'm NEW to TypeScript. I figured this would be a simple thing to try out to get started. Was I wrong? Maybe I just need to go read the documentation.Eric Burchamhttps://www.blogger.com/profile/01871133830095696088noreply@blogger.comtag:blogger.com,1999:blog-2194307155784714841.post-81536129232381394802013-08-10T00:10:54.022+02:002013-08-10T00:10:54.022+02:00@Ronnie, thanks much for the update. I really app...@Ronnie, thanks much for the update. I really appreciate that :)Eric Burchamhttps://www.blogger.com/profile/01871133830095696088noreply@blogger.comtag:blogger.com,1999:blog-2194307155784714841.post-71573537440435106422013-08-02T16:00:03.444+02:002013-08-02T16:00:03.444+02:00Hi Eric,
Thanks for the comment, don't be emba...Hi Eric,<br />Thanks for the comment, don't be embarrased, you found a bug ;-)<br /><br />I made a test on your example, and I also gets the error. This is because ga doesn't extends Node. I thought I have committet this months ago! it's now committet, the change to the d.ts file is pasted below<br /><br />interface GoogleAnalytics extends Node {<br /> type: string;<br /> src: string;<br /> async: bool;<br />}<br /><br />/ronnieAnonymoushttps://www.blogger.com/profile/05784212143757034903noreply@blogger.comtag:blogger.com,1999:blog-2194307155784714841.post-55981388540826372192013-07-30T05:19:41.928+02:002013-07-30T05:19:41.928+02:00I'm a little embarrassed. I got the TypeScrip...I'm a little embarrassed. I got the TypeScript definitions downloaded, referenced them from my new TypeScript file, and intellisense is working perfectly. But I cannot, for the life of me, figure how to get it to work. I'm using something like this:<br /><br />ga = document.createElement("script");<br />ga.async = true;<br />ga.src = '//www.google-analytics.com/analytics.js';<br />ga.type = 'text/javascript';<br />document.body.appendChild(ga);<br /><br />But when I try to compile the .ts file, I get the following error: "Type 'GoogleAnalytics' is missing property 'nodeType' from type 'Node'."<br /><br />Any chance you could put up a SUPER-simple example .ts file to just load the analytics script and track a pageview?Eric Burchamhttps://www.blogger.com/profile/01871133830095696088noreply@blogger.com