Permalink
Browse files

Decode cookie before parsing. Use click instead of mousedown. Use jqu…

…ery instead of setAttribute.
  • Loading branch information...
1 parent a4003fa commit 2673fd100b320e749de5cbb146a29003ed5c055c @fmoga fmoga committed Dec 7, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −2 experiments/media/js/experiments.js
  2. +3 −1 experiments/middleware.py
@@ -11,9 +11,9 @@ experiments = function() {
if (document.addEventListener) {
// sets the cookie in the capturing phase so that in the bubbling phase we guarantee that if a request is being issued it will contain the new cookie as well
- document.addEventListener("mousedown", function(event) {
+ document.addEventListener("click", function(event) {
if ((event.target).hasAttribute('data-experiments-goal')) {
- $.cookie("experiments_goal", (event.target).getAttribute('data-experiments-goal'), { path: '/' });
+ $.cookie("experiments_goal", $(event.target).data('experiments-goal'), { path: '/' });
}
}, true);
} else { // IE 8
@@ -1,10 +1,12 @@
from experiments import record_goal
+from urllib import unquote
+
class ExperimentsMiddleware(object):
def process_response(self, request, response):
experiments_goal = request.COOKIES.get('experiments_goal', None)
if experiments_goal:
- for goal in experiments_goal.split('%20'): # multiple goals separated by space
+ for goal in unquote(experiments_goal).split(' '): # multiple goals separated by space
record_goal(goal, request)
response.delete_cookie('experiments_goal')
return response

0 comments on commit 2673fd1

Please sign in to comment.