MediaWiki:DonationForm.js: Difference between revisions
Content deleted Content added
linting and alignment |
add utm_key and initial tracking - viewport width/height and time taken on page |
||
Line 4:
var donationForm = {};
donationForm.loadedTime = Date.now();
donationForm.extraData = {
'vw' : window.innerWidth,
'vh' : window.innerHeight
};
donationForm.minimums = {
Line 597 ⟶ 603:
full_dotted_payment_method = form.payment_method.value + '.' + paymentSubMethod;
}
donationForm.extraData.time = Math.round( (Date.now() - donationForm.loadedTime)/1000 );
form.utm_medium.value = mw.util.getParamValue( 'utm_medium' );
form.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
form.utm_source.value = donationForm.buildUtmSource() + '.' + full_dotted_payment_method;
form.utm_key.value =
form.method = 'GET';
Line 638 ⟶ 646:
return utm_source;
};
/**
* Build a string for utm_key from extra tracking data
*
* @param {Object} data
* @return {string} utm_key
*/
donationForm.buildUtmKey = function(data) {
var dataArray = [];
for (var key in data) {
if (data.hasOwnProperty(key)) {
dataArray.push( key + '_' + data[key] );
}
}
return dataArray.join('.');
};
|