Donorbox now provides a way to pass donation details to the conversion tracking scripts like Facebook Pixel and Google Adwords Conversion tracking. To enable this feature, Donorbox initializes a global javascript object 'DONORBOX' which will contain the 'donation' object after the successful donation is made. Thus DONORBOX.donation will be available for after donation tracking scripts to leverage the benefit of conversion tracking scripts.



Below are the examples illustrating the use of the javascript object for fetching donation details in conversion tracking scripts.


Facebook Pixel Tracking Example


<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');

  fbq('init', 'XXXXXXXXX', {
    
    em: DONORBOX.donation.email,
    fn: DONORBOX.donation.firstName,
    ln: DONORBOX.donation.lastName,
    ph: DONORBOX.donation.phone,
    
  });

  fbq('track', 'Purchase', {
    
    value: DONORBOX.donation.amount,
    currency: DONORBOX.donation.currency
    
  });
</script>
<noscript>
<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=XXXXXXXXX&amp;ev=PageView&amp;noscript=1"/>
</noscript>



Adwords Conversion Tracking Example


<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-XXXXXXXXX');
  gtag('event', 'conversion', {
    
    'send_to': 'AW-XXXXXXXXX/XXXXXXXXXXXXXXXXXXX',
    'value': DONORBOX.donation.amount,
    'currency': DONORBOX.donation.currency,
    'transaction_id': DONORBOX.donation.id
    
  });
</script>