MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
new buildUtmSource method to replace addAnalytics
remove addAnalytics method, move tracking inside redirectPayment
Line 574:
 
// WorldPay override for cc
if ( paymentMethod === 'cc-wp' ) {
paymentMethod = 'cc';
form.payment_method.value = 'cc';
Line 599:
form.payment_method.value = paymentMethod;
form.payment_submethod.value = paymentSubMethod;
 
donationForm.addAnalytics();
 
var full_dotted_payment_method = paymentMethod;
Line 610 ⟶ 608:
}
 
form.utm_sourceutm_medium.value + = mw.util.getParamValue( '.utm_medium' + full_dotted_payment_method);
form.utm_campaign.value = getQuerystringmw.util.getParamValue( 'utm_campaign' );
form.utm_source.value = donationForm.buildUtmSource() + '.' + full_dotted_payment_method;
form.utm_key.value = mw.util.getParamValue( 'utm_key' );
 
form.method = "'GET"';
form.submit();
}
Line 619 ⟶ 620:
};
 
/**
* Build a utm_source value, including the landing page info.
*
* Note this doesn't include payment method, that's added in redirectPayment method
*
* @return {string} utm_source
*/
Line 648 ⟶ 649:
 
}
 
donationForm.addAnalytics = function() {
// stuffs parameters into utm_source to make them available for analytics
// TODO: replace getQueryString with mw.util.getParamValue()
 
var form = document.paypalcontribution;
 
form.utm_source.value = getQuerystring( 'utm_source' ) + '.';
 
if(getQuerystring( 'template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
}
 
if(getQuerystring( 'appeal-template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
}
 
if(getQuerystring( 'appeal' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
}
 
if(getQuerystring( 'form-template' ) == '') {
form.utm_source.value += 'default' + '~';
} else {
form.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
}
 
if(getQuerystring( 'form-countryspecific' ) == '') {
form.utm_source.value += 'control';
} else {
form.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
}
 
form.utm_campaign.value = getQuerystring( 'utm_campaign' );
};
 
/* Return amount selected or input */