SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1383|回复: 0
打印 上一主题 下一主题

When Google Analytics meets SAS

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2011-12-1 04:13:04 | 只看该作者

When Google Analytics meets SAS

From Dapangmao's blog on sas-analysis

<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-8effPOa_Ie4/TtaNDsJdf-I/AAAAAAAAA24/JUk7oxWL5Qg/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-8effPOa_Ie4/TtaNDsJdf-I/AAAAAAAAA24/JUk7oxWL5Qg/s400/1.jpg" width="400" /></a></div>Thanks to <a href="http://www.bi-notes.com/">Tricia</a>’s introduction, I recently realized that <a href="http://www.google.com/analytics/">Google Analytics</a> is such a powerful tool for web analytics or business intelligence. It will fit the special needs if we use SAS to analyze the well-structure users’ data accumulated in Google Analytics. The challenge is that Google Analytics API and SAS hardly meet each other: Google Analytics often serves web/Linux, and SAS dwells in the ecosystems of Windows/UNIX/Mainframe.   On a Windows-equipped computer, I tried three methods to pull out this blog’s data from Google Analytics to SAS: they have their own pros and cons. <br />
<br />
<b>Method 1:  CliendLogin + HTTP protocol </b><br />
The <a href="http://code.google.com/apis/analytics/docs/gdata/gdataAuthentication.html">Data Export API</a> of Google Analytics has 3 types of authorization, and ClientLogin is one of them.  After downloading a token, the information from Google Analytics can be received through the HTTP protocol. William Roehl has<a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CCIQFjAA&amp;url=http%3A%2F%2Fsupport.sas.com%2Fresources%2Fpapers%2Fproceedings10%2F049-2010.pdf&amp;ei=LYzWTs2uEYTM2AXSsryJAQ&amp;usg=AFQjCNEisSwttMXsGIC-SjDgqQ2ZVPkGVg&amp;sig2=nZyLzReuEYDE9UT2y_UxrA"> a wonderful paper </a>to describe how to pass the authorization step and then parse the XML data by applying two SAS macros. .  R’s <a href="http://code.google.com/p/r-google-analytics/">RGoogleAnalytics</a> package and Python’s <a href="https://github.com/clintecker/python-googleanalytics">GA library</a> are also based the similar principles.<br />
<b>Pro:</b> simple and effective. A client user can choose SAS, R or Python to download data. The codes are all open-sourced and easy to get modified for any particular need. <br />
<b>Con:</b>  they all need cURL to set up SSL connection while downloading data. Since cURL is not built for Windows, it’s really awkward to use cURL on a PC which could fail many attempts. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/--RnVK5j1ueM/TtaNWp50aOI/AAAAAAAAA3E/mfvdWa9lpZg/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="http://3.bp.blogspot.com/--RnVK5j1ueM/TtaNWp50aOI/AAAAAAAAA3E/mfvdWa9lpZg/s400/2.jpg" width="400" /></a></div><br />
<b>Method 2:  Data Feed Query Explorer</b><br />
Google Analytics API has a <a href="http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html">web portal</a> to supply data. It uses a browser to realize the operations above. <br />
<b>Pro:</b> the easiest solution. The portal provides all options for the metrics, dimensions and segments. <br />
<b>Con:</b> the data has to be re-structured in SAS. It is getting slow when displaying a lot of results. <br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-VOwCmNR_wGU/TtaNbPB2UfI/AAAAAAAAA3Q/ufp135ZSQ0I/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="340" src="http://3.bp.blogspot.com/-VOwCmNR_wGU/TtaNbPB2UfI/AAAAAAAAA3Q/ufp135ZSQ0I/s400/3.jpg" width="400" /></a></div><br />
<br />
<b>Method 3: OAuth + Google’s Python client library </b><br />
OAuth is another authorization method. To obtain the necessary client’s key and secret for this approach, Google Analytics API has to be activated from <a href="https://code.google.com/apis/console/">Google API Console</a>.<br />
<b>Pro:</b> this authorization method is recommended by Google. <a href="http://code.google.com/p/gdata-python-client/">The official Python library</a> is very fast. Data downloaded in Python can be saved as CSV and then incorporated by SAS. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-n5r0Au9rNLA/TtaNs-F76vI/AAAAAAAAA3c/3Uor7wH1TUE/s1600/4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://3.bp.blogspot.com/-n5r0Au9rNLA/TtaNs-F76vI/AAAAAAAAA3c/3Uor7wH1TUE/s400/4.jpg" width="400" /></a></div><br />
<b>Con:</b>  a little complicated. A SAS user has to learn some Python to tweak the codes. <br />
<br />
Overall, Google Analytics now kicks off a <a href="http://analytics.blogspot.com/">new web interface</a> which has high learning curve. Using it's Data Export API as a front-end database and SAS as a back-end analytics platform will help generate customized models.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3256159328630041416-463535247802520186?l=www.sasanalysis.com' alt='' /></div><img src="http://feeds.feedburner.com/~r/SasAnalysis/~4/fZl02PCBuLk" height="1" width="1"/>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-9-6 21:36 , Processed in 0.086963 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表