-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogleanalytics
155 lines (143 loc) · 3.94 KB
/
googleanalytics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/sh
##########################################################################
# Title : googleanalytics - download Google Analytics data
# Author : Jay Ridgeway <jayridge AT gmail.com>
# Date : 2006-02-20
# Requires : curl
# $Id: googleanalytics,v 1.1 2007/02/20 22:35:03 jayridgeway Exp jayridgeway $
##########################################################################
# Description
#
##########################################################################
PN=`basename "$0"` # program name
VER=`echo '$Revision: 1.1 $' | cut -d' ' -f2`
CURL='curl'
Usage () {
echo "$PN - download Google Analytics data in csv, $VER (jayridge '07)
usage: $PN -u user -p passwd -r report [-s start] [-e end] [-t type]
Where user is [email protected], passwd is your google passwd, start is start date
of report in YYYYMMDD format, end is end date in YYYYMMDD format, report is the
profile id of analytics account (visible as rid=<report> when viewing a report
in GA and type is one of thefollowing:
EXECUTIVE_OVERVIEW=2001
CONVERSION_SUMMARY_1=2003
CONVERSION_SUMMARY_2=2108
MARKETING_SUMMARY_1=2004
MARKETING_SUMMARY_2=2102
CONTENT_SUMMARY_1=2005
CONTENT_SUMMARY_2=2202
SITE_OVERLAY_1=2007
SITE_OVERLAY_2=2109
SITE_OVERLAY_3=1312
SITE_OVERLAY_4=1351
MARKETER_OVERVIEW=2101
CPC_PROGRAM_ANALYSIS_1=2103
CPC_PROGRAM_ANALYSIS_2=1220
CPC_VS_ORGANIC_CONVERSION_1=2104
CPC_VS_ORGANIC_CONVERSION_2=1222
OVERALL_KEYWORD_CONVERSION_1=2105
OVERALL_KEYWORD_CONVERSION_2=1221
KEYWORD_CONSIDERATIONS_1=2106
KEYWORD_CONSIDERATIONS_2=1223
CAMPAIGN_CONVERSION_1=2107
CAMPAIGN_CONVERSION_2=1213
DEFINED_FUNNEL_NAVIGATION_1=2110
DEFINED_FUNNEL_NAVIGATION_2=2203
DEFINED_FUNNEL_NAVIGATION_3=1318
ENTRANCE_BOUNCE_RATES_1=2111
ENTRANCE_BOUNCE_RATES_2=2204
ENTRANCE_BOUNCE_RATES_3=1310
WEBMASTER_OVERVIEW=2201
GOAL_TRACKING_1=2205
GOAL_TRACKING_2=1315
CONTENT_BY_TITLES_1=2206
CONTENT_BY_TITLES_2=1306
BROWSER_VERSIONS_1=2207
BROWSER_VERSIONS_2=1321
PLATFORM_VERSIONS_1=2208
PLATFORM_VERSIONS_2=1322
BROWSER_AND_PLATFORM_COMBOS_1=2209
BROWSER_AND_PLATFORM_COMBOS_2=1323
SCREEN_RESOLUTIONS_1=2210
SCREEN_RESOLUTIONS_2=1324
SCREEN_COLORS_1=2211
SCREEN_COLORS_2=1325
LANGUAGES_1=2312
LANGUAGES_2=1326
JAVA_ENABLED_1=2213
JAVA_ENABLED_2=1327
FLASH_VERSION_1=2215
FLASH_VERSION_2=1329
CONNECTION_SPEED_1=2216
CONNECTION_SPEED_2=1330
HOSTNAMES_1=2217
HOSTNAMES_2=1331
DAILY_VISITORS=1201
VISITS_AND_PAGEVIEW_TRACKING=1202
GOAL_CONVERSION_TRACKING=1203
ABSOLUTE_UNIQUE_VISITORS=1204
VISITOR_LOYALTY=1205
VISITOR_RECENCY=1206
NEW_VS_RETURNING=1207
REFERRING_SOURCE_=1208
GEO_LOCATION=1209
GEO_MAP_OVERLAY=1227
NETWORK_LOCATION=1210
LANGUAGE=1211
USER-DEFINED=1212
DOMAINS=1231
SOURCE_CONVERSION=1214
MEDIUM_CONVERSION=1215
REFERRAL_CONVERSION=1216
CAMPAIGN_ROI=1217
SOURCE_ROI=1218
MEDIUM_ROI=1219
OVERALL_AD_A/B_TESTING=1301
SOURCE_SPECIFIC_TESTING_=1302
KEYWORD_SPECIFIC_TESTING=1303
TOP_CONTENT=1304
CONTENT_DRILLDOWN=1305
DYNAMIC_CONTENT=1307
DEPTH_OF_VISIT=1308
LENGTH_OF_VISIT_=1309
TOP_EXIT_POINTS=1311
INITIAL_NAVIGATION=1313
ALL_NAVIGATION=1314
GOAL_CONVERSION=1316
DEFINED_FUNNEL_ABANDONMENT=1317
REVERSE_GOAL_PATH=1319
GOAL_VERIFICATION=1320" >&2
exit 1
}
if [ $# -eq 0 ]; then
Usage
fi
Type=2001 ; # defaults to executive overview
while [ $# -gt 0 ]
do
case "$1" in
-u) Email=$2;;
-p) Passwd=$2;;
-s) Start=$2;;
-r) Report=$2;;
-t) Type=$2;;
-e) End=$2;;
--) shift; break;;
-h|-*) break;;
esac
shift
done
if [ ! -n "$Email" ] || [ ! -n "$Passwd" ] || [ ! -n "$Report" ]
then
Usage
fi
COOKIES=${TMPDIR:=/tmp}/cookies$$.tmp
LOGINURL='https://www.google.com/accounts/ServiceLoginBoxAuth'
POST="service=analytics&Email=${Email}&Passwd=${Passwd}&PersistentCookie=yes"
${CURL} -s -c ${COOKIES} -d ${POST} ${LOGINURL} > /dev/null
REPORTURL="https://www.google.com/analytics/home/report"
REPORTURL=${REPORTURL}"?rid=${Report}&vid=${Type}&bd=${Start}&ed=${End}"
REPORTURL=${REPORTURL}"&ss=0&dcomp=0&xd=1&dow=0&dt=3&dtc=2&x=3"
echo ${REPORTURL}
${CURL} -s -b ${COOKIES} ${REPORTURL}
rm ${COOKIES}