Jump to content

Obsolete:Fundraising Tracking/TrackingJS

From Wikitech
This page contains historical information. It may be outdated or unreliable.
function redirectPayment(i) {
    //if i == 1
    var paymentType ="cc";
    var action_url = "https://payments.wikimedia.org/index.php/Special:PayflowProGateway?uselang=</html>{{{language}}}<html>" ;
    if (i==2) {action_url="http://wikimediafoundation.org/wiki/Special:ContributionTracking/</html>{{{language|{{BASEPAGENAME}}}}}<html>";
   paymentType = "pp";
   }
    
    document.paypalcontribution.action = action_url;
    document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.' + getLandingPage() + '.' + paymentType;
   if(validateForm(document.paypalcontribution)){
      document.paypalcontribution.submit();
    }
}

function getQuerystring( key )
{
  key = key.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' );
  var regex = new RegExp( '[\\?&]' + key + '=([a-zA-Z0-9\_\-]*)' );
  var qs = regex.exec( window.location.search );
  return qs == null ? '' : qs[1];
}

function getLandingPage()
{
   
   var path = "</html>{{{landing-page|default}}}<html>";

   if( path == "default"){
      pathArray = window.location.pathname.split( '/' );
      return pathArray[2];
   }
   else return path;
}

function updateCC( currency ) {
        document.getElementById('cc-donate-button').style.display = "none";
} 
	 
document.paypalcontribution.utm_medium.value = getQuerystring( 'utm_medium' );
document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' );
document.paypalcontribution.referrer.value = document.referrer;
window.onload = updateCC(document.getElementById('input_currency_code').value);