aboutsummaryrefslogtreecommitdiffstats
path: root/analyse-ga-usage
blob: ce158c08e758c7e6d35cf119b960b8b0f790be51 (plain)
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
#!/bin/sh

dataset="har-data/*.har"
#dataset="har-data/*kommune.no.har"

gaurl() {
    egrep -l '"url": .*(google-analytics.com|http://www.usit.uio.no/vrtx/decorating/resources/dist/urchin/__utm.gif)' $dataset
}

gausers() {
    egrep -l '"url": .*(google-analytics.com/__utm.gif|google-analytics.com/collect|google-analytics.com/r/__utm.gif|google-analytics.com/r/collect|http://www.usit.uio.no/vrtx/decorating/resources/dist/urchin/__utm.gif)' $dataset
}

gaaipusers() {
    egrep -l '"url": .*google-analytics.com/.*aip=1' $dataset
}

piwikusers() {
    egrep -l '"url": .*piwik' $dataset
}

fbusers() {
    egrep -l '"url": .*facebook.com' $dataset
}

twusers() {
    egrep -l '"url": .*twitter.com' $dataset
}

total=$(ls $dataset | wc -l)
gaurl=$(gaurl | wc -l)
gausers=$(gausers | wc -l)
gaaipusers=$(gaaipusers | wc -l)
piwikusers=$(piwikusers | wc -l)
fbusers=$(fbusers | wc -l)
twusers=$(twusers | wc -l)

printf "%d (%.1f%%) of %d contacts google-analytics.com\n" "$gaurl" "$(echo 100 \* $gaurl / $total | bc -l)" "$total"
printf "%d (%.1f%%) of %d mentions piwik\n" "$piwikusers" "$(echo 100 \* $piwikusers / $total | bc -l)" "$total"
printf "%d (%.1f%%) of %d mentions twitter\n" "$twusers" "$(echo 100 \* $twusers / $total | bc -l)" "$total"
printf "%d (%.1f%%) of %d mentions facebook\n" "$fbusers" "$(echo 100 \* $fbusers / $total | bc -l)" "$total"
printf "%d (%.1f%%) of %d submits to google-analytics.com\n" "$gausers" "$(echo 100 \* $gausers / $total | bc -l)" "$total"
printf "%d (%.1f%%) of %d uses aip=1 in the GA URL\n" "$gaaipusers" "$(echo 100 \* $gaaipusers / $gausers | bc -l)" "$gausers"

if [ "$1" = "-v" ] ; then
    tfile=$(mktemp)
    gaurl |sort > $tfile
    gausers |sort | comm -3 $tfile -
    rm $tfile
fi

if [ "$1" = "-q" ] ; then
    tfile=$(mktemp)
    gaaipusers |sort > $tfile
    gausers |sort | comm -3 $tfile -
    rm $tfile
fi
if [ "$1" = "-o" ] ; then
    gaaipusers
fi