{"id":884,"date":"2010-12-10T13:25:46","date_gmt":"2010-12-10T10:25:46","guid":{"rendered":"http:\/\/blog.denivip.ru\/?p=884"},"modified":"2022-05-13T12:56:05","modified_gmt":"2022-05-13T08:56:05","slug":"open-source-actionscript-3-google-analytics-api","status":"publish","type":"post","link":"http:\/\/blog.denivip.ru\/index.php\/2010\/12\/open-source-actionscript-3-google-analytics-api\/","title":{"rendered":"Open Source ActionScript 3 Google Analytics API"},"content":{"rendered":"<p style=\"text-align:center;\"><a href=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2010\/12\/google-name.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2010\/12\/google-name.jpg\" alt=\"\" title=\"google analytics\" width=\"297\" height=\"259\" class=\"alignnone size-full wp-image-886\" \/><\/a><\/p>\n<p>We have published sources and all information about recently developed AS3 Google Analytics API. We would like to see you uncovering potential of Google Analytics in your Flash and AIR applications. It is in the early stage of development but already gives you powerful tools of access to analytics data in simple and flexible form. We will continue to develop AS3 Google Analytics API and add new features, that&#8217;s why we would like to get your feedback and feature requests. Visit <a href=\"http:\/\/labs.denivip.ru\/projects\/asapiga\" onclick=\"_gaq.push(['_trackEvent', 'Engagement', 'Redirect', 'labs']);\" target=\"_blank\" rel=\"noopener noreferrer\">project page<\/a>. <!--more--><\/p>\n<p>Using AS3 Google Analytics API is pretty simple as several lines of code. First of all import swc library into your project and all needed classes in your package.<\/p>\n<p><strong>Download<\/strong><br \/>\nDownload latest version <a href=\"http:\/\/labs.denivip.ru\/projects\/asapiga\/repository\/revisions\/master\/show\/bin\" onclick=\"_gaq.push(['_trackEvent', 'Engagement', 'Download', 'labs']);\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. It could be useful to download sources as well.<\/p>\n<p><strong>Requesting data feed<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/><\/div><\/td><td><div class=\"text codecolorer\">var apiloader_ga:APILoader = new APILoader();<br \/>\nvar gav:GAView = new VisitorsView();<br \/>\n\/\/ Configure your google account profile id<br \/>\napiloader_ga.setProfileID(&quot;ga:profilenum&quot;);<br \/>\n\/\/ Configure dimensions to request from GA<br \/>\napiloader_ga.setDimensions(new Array(new VisitorDateDimension()));<br \/>\n\/\/ Configure metrics to request from GA<br \/>\napiloader_ga.setMetrics(new Array(new VisitorVisitsMetric() ));<br \/>\n\/\/ Configure request filter<br \/>\napiloader_ga.setFilter(new Filter(new FilterItem(new VisitorCountryDimension(), new FilterOperator(&quot;==&quot;),&quot;Russia&quot;)));<br \/>\n\/\/ Analytics data timeframe setup<br \/>\nvar start_date:Date = new Date(2010, 10, 9);<br \/>\nvar end_date:Date = new Date(2010, 11, 8);<br \/>\napiloader_ga.setPeriod(start_date, end_date);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n\/\/ Set callback function (returns array of DataFeedResponse objects)<br \/>\napiloader_ga.setCallback(refreshGraph);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n\/\/ Configure view (process data and prepares everything in your way)<br \/>\n\/\/ You could pass any class implementing GAView or choose from already developed<br \/>\napiloader_ga.registerView(gav);<br \/>\n<br \/>\n\/\/ Connect and begin data loading<br \/>\napiloader_ga.connect(new GAAccount(&quot;yourgmail@gmail.com&quot;, &quot;yourpassword&quot;));<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>Retrieving results<\/strong><br \/>\nYou could get results in two ways.<br \/>\nFirst one is by using callback function where you get an array of DataFeedResponse objects<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"text codecolorer\">function refreshGraph(a:Array):void {<br \/>\n\/\/ parse an array of DataFeedResponse objects<br \/>\n}<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Second approach is in providing GAView descendant object to APILoader object. APILoader during consequent pages loading will be filling GAView object with data. You may check sample implementation in com.denivip.ga.view.VisitorsView class.<\/p>\n<p><strong>Sample<\/strong><br \/>\nIn order to quickly integrate Google Analytics API into your Flash application please check our demo app source codes. It shows visitors from Russia on your site (you should compile with your profile id and account credentials). <a href='http:\/\/blog.denivip.ru\/wp-content\/uploads\/2010\/12\/TiViCon.zip' onclick=\"_gaq.push(['_trackEvent', 'Engagement', 'Download', 'labs']);\" target=\"_blank\" rel=\"noopener noreferrer\">Sources<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have published sources and all information about recently developed AS3 Google Analytics API. We would like to see you uncovering potential of Google Analytics in your Flash and AIR applications. It is in the early stage of development but already gives you powerful tools of access to analytics data in simple and flexible form. [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,20],"tags":[198,199,16,24],"_links":{"self":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/884"}],"collection":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/comments?post=884"}],"version-history":[{"count":11,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/884\/revisions"}],"predecessor-version":[{"id":5624,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/884\/revisions\/5624"}],"wp:attachment":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/media?parent=884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/categories?post=884"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/tags?post=884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}