Donorbox now provides a way to pass donation details to conversion tracking scripts like Facebook Pixel and Google Adwords conversion tracking. To enable this feature, Donorbox initializes a global JavaScript ('DONATION') object which will contain the 'donation' object after the successful donation is made. Thus DONORBOX.donation will be available after the 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
!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', { <strong> em: DONORBOX.donation.email, fn: DONORBOX.donation.firstName, ln: DONORBOX.donation.lastName, ph: DONORBOX.donation.phone, </strong> }); fbq('track', 'Purchase', { <strong> value: DONORBOX.donation.amount, currency: DONORBOX.donation.currency </strong> });![]()
Adwords Conversion Tracking Example
window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-XXXXXXXXX'); gtag('event', 'conversion', { <strong> 'send_to': 'AW-XXXXXXXXX/XXXXXXXXXXXXXXXXXXX', 'value': DONORBOX.donation.amount, 'currency': DONORBOX.donation.currency, 'transaction_id': DONORBOX.donation.id </strong> });
Comments
0 comments
Please sign in to leave a comment.