Created
April 16, 2014 05:31
-
-
Save THEtheChad/10811330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ajaxSuccess(function(evt, res, req){ | |
// here's where we look for our signature | |
if('/apps/mytmobile/eservice/servlet/UserProfile' != req.url) return; | |
if(!/UPDATE_NAME/.test(req.data)) return; | |
// extract ['key=value'] pairs | |
var params = {}, data; | |
data = req.data; | |
data = decodeURIComponent(data); | |
data = data.split('&'); | |
// convert ['key=value'] pairs to an object | |
var i = data.length; | |
while(i--){ | |
var d = data[i].split('='); | |
params[ d[0] ] = d[1]; | |
} | |
// convert formData 'string' to json [{}] | |
var formData = []; | |
try{ | |
formData = JSON.parse(params.formData); | |
} catch(e){} | |
// convert the odd json [{}] syntax to an actual object | |
var i = formData.length; | |
var d = params.formData = {}; | |
while(i--){ | |
var node = formData[i]; | |
d[ node.name ] = node.value; | |
} | |
// fire custom code to track event here | |
s.prop1 = d.firstName + d.lastName; | |
s.events = 'Update Username'; | |
s.tl(null, 'o', 'Update Username'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment