MediaWiki:DonationForm.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
new buildUtmSource method to replace addAnalytics |
remove addAnalytics method, move tracking inside redirectPayment |
||
Line 574: | Line 574: | ||
// WorldPay override for cc |
// WorldPay override for cc |
||
if( paymentMethod === 'cc-wp' ) { |
if ( paymentMethod === 'cc-wp' ) { |
||
paymentMethod = 'cc'; |
paymentMethod = 'cc'; |
||
form.payment_method.value = 'cc'; |
form.payment_method.value = 'cc'; |
||
Line 599: | Line 599: | ||
form.payment_method.value = paymentMethod; |
form.payment_method.value = paymentMethod; |
||
form.payment_submethod.value = paymentSubMethod; |
form.payment_submethod.value = paymentSubMethod; |
||
donationForm.addAnalytics(); |
|||
var full_dotted_payment_method = paymentMethod; |
var full_dotted_payment_method = paymentMethod; |
||
Line 610: | Line 608: | ||
} |
} |
||
form. |
form.utm_medium.value = mw.util.getParamValue( 'utm_medium' ); |
||
⚫ | |||
form.utm_source.value = donationForm.buildUtmSource() + '.' + full_dotted_payment_method; |
|||
form.utm_key.value = mw.util.getParamValue( 'utm_key' ); |
|||
form.method = |
form.method = 'GET'; |
||
form.submit(); |
form.submit(); |
||
} |
} |
||
Line 619: | Line 620: | ||
}; |
}; |
||
/** |
/** |
||
* Build a utm_source value, including the landing page info. |
* Build a utm_source value, including the landing page info. |
||
* |
* |
||
* Note this doesn't include payment method, that's added in redirectPayment method |
* Note this doesn't include payment method, that's added in redirectPayment method |
||
* |
* |
||
* @return {string} utm_source |
* @return {string} utm_source |
||
*/ |
*/ |
||
Line 648: | Line 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-",""); |
|||
} |
|||
⚫ | |||
}; |
|||
/* Return amount selected or input */ |
/* Return amount selected or input */ |