<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NPK7NF9" height="0" width="0" style="display:none;visibility:hidden">

HubSpot Integration

This integration script is a template based on our JS API and may be customized to your own needs

Note: In addition to tracking donor events, you can also choose to sync donation data via Zapier.

Getting Started

The HubSpot tracking code is unique to each HubSpot account and allows HubSpot to monitor your website traffic.

Please see more at https://knowledge.hubspot.com/reports/install-the-hubspot-tracking-code

 

Track Events

Events are used to track that some action that occurs, and can be tied to a contact record so that you can see if/when a contact triggered that event.  We assume that in most cases you'd want to see if your HS contacts have attempted to donate and if they complete a donation.

Note: Events will only be processed for accounts with Marketing Hub Enterprise.

<script>

// track checkout open
FundraiseUp.on('checkoutOpen', function(details) {
_hsq.push(["trackEvent", {
id: "Fundraise Up Checkout Started"
}]
);

});

// track completed donation 
FundraiseUp.on('donationComplete', function(details) {

var eventName = 'Fundraise Up One Time Donation';

if (details.donation.recurring) {
eventName = 'Fundraise Up Monthly Donation'
}

_hsq.push(['trackEvent', {
id: eventName,
value: details.donation.amount
}]);
});

</script>


Track  Contact

This is used to identify a visitor to your site. The unique identifier is an email address. If there is an existing contact record for that email address, it will be updated. Otherwise, a new contact record will be created. In both cases, the analytics data collected for the visitor will be associated with the contact record. 

<script>

FundraiseUp.on('donationComplete', function(details) {

var _hsq = window._hsq = window._hsq || [];
var user = details.supporter;
var customFields = details.customFields;

/*
This sets the email,
as well as custom properties of your contact.
Note: your custom properties MUST be created first within your HubSpot account.
*/

_hsq.push(['identify', {
email: user.email,
firstname: user.firstName,
lastname: user.lastName,

// optionally map any of the available Fundraise Up datapoints
// to your custom HubSpot properties

platform: 'Fundraise Up',
last_donation_amount: details.donation.amount,
last_donation_currency: details.donation.currency,
last_donation_frequency: details.donation.recurring ? 'Monthly' : 'One Time',
last_donation_date_utc: new Date().setUTCHours(0,0,0,0),

// optionally map custom fields such us UTM tags.
utm_source: customFields.utm_source,
utm_medium: customFields.utm_medium,
utm_campaign: customFields.utm_campaign,
utm_term: customFields.utm_term,
utm_keyword: customFields.utm_keyword,
utm_content: customFields.utm_content,
}]);

// send data to HS
_hsq.push(['trackPageView']);

});

</script>

Track Form

If you really want to get fancy with HubSpot, you may want to see the Fundraise Up Checkout experience as submitting a form with multiple fields. You may want to create an Automation Workflow in your HubSpot account that processes the submitted data (for example, create new Deal for each submitted donation, and enroll in a welcome series)

Note: You MUST create the form in your HubSpot account FIRST  with all fields you want to track. 

<script>

// create or update HS contact with information received from donation
 
FundraiseUp.on('donationComplete', function(details) {

// Replace portalId and formId with information from your FORM
var portalId = '7376849';
var formId = 'fdf6ffce-1a9a-4b61-b5ff-8e3d395ab05b';
var url = 'https://api.hsforms.com/submissions/v3/integration/submit/' + portalId + '/' + formId;

// Build request JSON:
var data = {
'submittedAt': Date.now(),
'fields': [
{
'name': 'campaign_id',
'value': details.campaign.id
},
{
'name': 'campaign_code',
'value': details.campaign.code ? details.campaign.code : ''
},
{
'name': 'campaign_name',
'value': details.campaign.name
},
{
'name': 'donation_id',
'value': details.donation.id
},
{
'name': 'donation_amount',
'value': details.donation.amount
},
{
'name': 'donation_currency',
'value': details.donation.currency
},
{
'name': 'donation_frequency',
'value': details.donation.recurring ? 'Monthly' : 'One Time'
},
{
'name': 'supporter_id',
'value': details.supporter.id
},
{
'name': 'supporter_first_name',
'value': details.supporter.firstName
},
{
'name': 'supporter_email',
'value': details.supporter.email
},
{
'name': 'supporter_utm_source',
'value': details.customFields.utm_source ? details.customFields.utm_source : ''
}

],
'context': {
'hutk': ':hutk' // include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission
},
'legalConsentOptions': { // Include this object when GDPR options are enabled
'consent': {
'consentToProcess': true,
'text':'I agree to allow Example Company to store and process my personal data.',
'communications': [
{
'value': true,
'subscriptionTypeId': 999, // replace with your subscription ID
'text':'I agree to receive marketing communications from Example Company.'
}
]
}
}
};

if (details.designation) {
var designationData = [
{
'name': 'designation_id',
'value': details.designation.id
},
{
'name': 'designation_name',
'value': details.designation.name
},
{
'name': 'designation_code',
'value': details.designation.code
},
];
data.fields = data.fields.concat(designationData);
}

// Create the new request
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.setRequestHeader('Content-Type', 'application/json');

// Sends the request
xhr.send(JSON.stringify(data));

});

</script>