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
=== modified file 'templates/dir_template.html'
--- templates/dir_template.html 2012-10-11 14:50:15 +0000
+++ templates/dir_template.html 2013-02-28 11:50:43 +0000
@@ -20,7 +20,23 @@
20 {% endif %}20 {% endif %}
2121
22{% for value in dirlist %}22{% for value in dirlist %}
23 <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>23 <tr>
24 <td valign="top">
25 <img src="{{ STATIC_URL }}/static/{{ value.type }}.png"
26 alt="{{ value.type }}"/>
27 </td>
28 <td>
29 <a href="{{ value.url }}"
30 {% if value.type != 'folder' %}
31 onclick="javascript:trackDownload(
32 'Download Attempted', '{{ value.url }}');"
33 {% endif %}
34 >{{ value.name }}</a>
35 </td>
36 <td align="right">{{ value.mtime }} </td>
37 <td align="right">
38 {% if value.type != 'folder' %}{{ value.size }}{% endif %}
39 </td>
24 <td>40 <td>
25 {% if value.license_digest_list == "OPEN" %}41 {% if value.license_digest_list == "OPEN" %}
26 <i>open</i>42 <i>open</i>
2743
=== added file 'templates/google-analytics.html'
--- templates/google-analytics.html 1970-01-01 00:00:00 +0000
+++ templates/google-analytics.html 2013-02-28 11:50:43 +0000
@@ -0,0 +1,18 @@
1 <script type="text/javascript">
2 var _gaq = _gaq || [];
3 _gaq.push(['_setAccount', 'UA-16756069-8']);
4 _gaq.push(['_trackPageview']);
5
6 (function() {
7 var ga = document.createElement('script'); ga.type = 'text/javascript';
8 ga.async = true;
9 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10 var s = document.getElementsByTagName('script')[0];
11 s.parentNode.insertBefore(ga, s);
12 })();
13 </script>
14 <script type="text/javascript">
15 var trackDownload = function(action, url) {
16 _gaq.push(['_trackEvent', 'Downloads', action, url]);
17 }
18 </script>
019
=== modified file 'templates/header.html'
--- templates/header.html 2013-02-26 20:24:11 +0000
+++ templates/header.html 2013-02-28 11:50:43 +0000
@@ -28,19 +28,7 @@
28 }28 }
29 </style>29 </style>
3030
31 <script type="text/javascript">31 {% include 'google-analytics.html' %}
32 var _gaq = _gaq || [];
33 _gaq.push(['_setAccount', 'UA-16756069-8']);
34 _gaq.push(['_trackPageview']);
35
36 (function() {
37 var ga = document.createElement('script'); ga.type = 'text/javascript';
38 ga.async = true;
39 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
40 var s = document.getElementsByTagName('script')[0];
41 s.parentNode.insertBefore(ga, s);
42 })();
43 </script>
44</head>32</head>
45<body>33<body>
46<div id="head">34<div id="head">
4735
=== modified file 'templates/license.html'
--- templates/license.html 2012-06-22 13:34:48 +0000
+++ templates/license.html 2013-02-28 11:50:43 +0000
@@ -3,6 +3,7 @@
3<html>3<html>
4<head>4<head>
5 {% block header %}{% endblock %}5 {% block header %}{% endblock %}
6 {% include 'google-analytics.html' %}
6</head>7</head>
7<body>8<body>
8 {% block content-header %}{% endblock %}9 {% block content-header %}{% endblock %}
@@ -10,7 +11,14 @@
10 {% block content-footer-top %}{% endblock %}11 {% block content-footer-top %}{% endblock %}
11 <form action="/accept-license?lic={{ license.digest }}&url={{ url }}" method="post">12 <form action="/accept-license?lic={{ license.digest }}&url={{ url }}" method="post">
12 {% csrf_token %}13 {% csrf_token %}
13 <input class="button button-accept" type="submit" value="Accept" name="accept" /> <input class="button button-decline" type="submit" value="Reject" name="reject"/>14 <input class="button button-accept" type="submit" value="Accept"
15 name="accept"
16 onclick="javascript:trackDownload('License Accepted', '{{ url }}');"
17 />
18 <input class="button button-decline" type="submit" value="Reject"
19 name="reject"
20 onclick="javascript:trackDownload('License Rejected', '{{ url }}');"
21 />
14 </form>22 </form>
15 {% block content-footer-bottom %}{% endblock %}23 {% block content-footer-bottom %}{% endblock %}
16</body>24</body>

Subscribers

People subscribed via source and target branches