Merge lp:~danilo/linaro-license-protection/download-stats into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Данило Шеган
Status: Merged
Approved by: Stevan Radaković
Approved revision: 171
Merged at revision: 172
Proposed branch: lp:~danilo/linaro-license-protection/download-stats
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 104 lines (+45/-15)
4 files modified
templates/dir_template.html (+17/-1)
templates/google-analytics.html (+18/-0)
templates/header.html (+1/-13)
templates/license.html (+9/-1)
To merge this branch: bzr merge lp:~danilo/linaro-license-protection/download-stats
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+151000@code.launchpad.net

Description of the change

Emit google analytics tracking events for downloads. Since we can't really do it server-side, we have to do this on the client side, and thus we can't track real 'download started' event.

The way we group events is open for future changes, but this should be a step forward.

To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

Looks good, thanks!
Approve +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'templates/dir_template.html'
2--- templates/dir_template.html 2012-10-11 14:50:15 +0000
3+++ templates/dir_template.html 2013-02-28 11:50:43 +0000
4@@ -20,7 +20,23 @@
5 {% endif %}
6
7 {% for value in dirlist %}
8- <tr><td valign="top"><img src="{{ STATIC_URL }}/static/{{ value.type }}.png" alt="{{ value.type }}"/></td><td><a href="{{ value.url }}">{{ value.name }}</a></td><td align="right">{{ value.mtime }} </td><td align="right"> {% if value.type != 'folder' %}{{ value.size }}{% endif %}</td>
9+ <tr>
10+ <td valign="top">
11+ <img src="{{ STATIC_URL }}/static/{{ value.type }}.png"
12+ alt="{{ value.type }}"/>
13+ </td>
14+ <td>
15+ <a href="{{ value.url }}"
16+ {% if value.type != 'folder' %}
17+ onclick="javascript:trackDownload(
18+ 'Download Attempted', '{{ value.url }}');"
19+ {% endif %}
20+ >{{ value.name }}</a>
21+ </td>
22+ <td align="right">{{ value.mtime }} </td>
23+ <td align="right">
24+ {% if value.type != 'folder' %}{{ value.size }}{% endif %}
25+ </td>
26 <td>
27 {% if value.license_digest_list == "OPEN" %}
28 <i>open</i>
29
30=== added file 'templates/google-analytics.html'
31--- templates/google-analytics.html 1970-01-01 00:00:00 +0000
32+++ templates/google-analytics.html 2013-02-28 11:50:43 +0000
33@@ -0,0 +1,18 @@
34+ <script type="text/javascript">
35+ var _gaq = _gaq || [];
36+ _gaq.push(['_setAccount', 'UA-16756069-8']);
37+ _gaq.push(['_trackPageview']);
38+
39+ (function() {
40+ var ga = document.createElement('script'); ga.type = 'text/javascript';
41+ ga.async = true;
42+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
43+ var s = document.getElementsByTagName('script')[0];
44+ s.parentNode.insertBefore(ga, s);
45+ })();
46+ </script>
47+ <script type="text/javascript">
48+ var trackDownload = function(action, url) {
49+ _gaq.push(['_trackEvent', 'Downloads', action, url]);
50+ }
51+ </script>
52
53=== modified file 'templates/header.html'
54--- templates/header.html 2013-02-26 20:24:11 +0000
55+++ templates/header.html 2013-02-28 11:50:43 +0000
56@@ -28,19 +28,7 @@
57 }
58 </style>
59
60- <script type="text/javascript">
61- var _gaq = _gaq || [];
62- _gaq.push(['_setAccount', 'UA-16756069-8']);
63- _gaq.push(['_trackPageview']);
64-
65- (function() {
66- var ga = document.createElement('script'); ga.type = 'text/javascript';
67- ga.async = true;
68- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
69- var s = document.getElementsByTagName('script')[0];
70- s.parentNode.insertBefore(ga, s);
71- })();
72- </script>
73+ {% include 'google-analytics.html' %}
74 </head>
75 <body>
76 <div id="head">
77
78=== modified file 'templates/license.html'
79--- templates/license.html 2012-06-22 13:34:48 +0000
80+++ templates/license.html 2013-02-28 11:50:43 +0000
81@@ -3,6 +3,7 @@
82 <html>
83 <head>
84 {% block header %}{% endblock %}
85+ {% include 'google-analytics.html' %}
86 </head>
87 <body>
88 {% block content-header %}{% endblock %}
89@@ -10,7 +11,14 @@
90 {% block content-footer-top %}{% endblock %}
91 <form action="/accept-license?lic={{ license.digest }}&url={{ url }}" method="post">
92 {% csrf_token %}
93- <input class="button button-accept" type="submit" value="Accept" name="accept" /> <input class="button button-decline" type="submit" value="Reject" name="reject"/>
94+ <input class="button button-accept" type="submit" value="Accept"
95+ name="accept"
96+ onclick="javascript:trackDownload('License Accepted', '{{ url }}');"
97+ />
98+ <input class="button button-decline" type="submit" value="Reject"
99+ name="reject"
100+ onclick="javascript:trackDownload('License Rejected', '{{ url }}');"
101+ />
102 </form>
103 {% block content-footer-bottom %}{% endblock %}
104 </body>

Subscribers

People subscribed via source and target branches