Setting Up eCommerce and Event Tracking

by Scott Dilley - CTO 07 May 2018

In addition to having advanced tracking capabilities via our own Custom Short Urls, each Funraisin powered site supports the ability to send through event and e-commerce data to platforms like Google Analytics and Facebook without requiring the need for developers to add bespoke code to individual pages. Currently we support the following e-commerce tracking methods:

  • GA (Google Analytics)
  • GTAG (Google Analytics as of April 2017)
  • GTM (Google Tag Manager)
  • Facebook
  • AutoPilot

It is also possible to implement custom tracking on most of your site’s pages however this article only covers our standard tracking feature.

 

Step 1. Adding your tracking tags

Before we can send data to your other platforms you will need to upload your tracking tags to your platform. These can be uploaded via Platform Setup > Tracking and Analytics as the illustration below shows. Simply select which tracking tags you wish to add and paste in the code provided by each platform.

 

You can also add in other custom tracking tags using the “other tracking code” option and specifying where on the page you wish for the code to appear, e.g.,etc.

 

 

Step 2. Defining the e-commerce data method for Google Analytics

For Google tracking we support GA, GTAG and GTM tags, so in order for us to send through the correct data you will need to tell us which method to use. Note that as of April 2017 Google will provide you with GTAG tracking tags by default however we do support the older GA tracking.

If you aren’t sure which method is best for your site please feel free to ask us for assistance.

Defining your tracking method can be done from Platform Setup > Tracking and Analytics > Event and E-commerce Tracking as shown below.

 

Step 3. Standard E-commerce & Event Data

Once your tracking tags have been added to your site we will start to send through the following e-commerce and event data to each platform we have tags for based on the type of activity on your site.

For help with setting up your tracking within Google see this article.


Sponsored Donations

Sponsored donations are ones made from someone’s fundraising page. For each successful donation the following data will be sent to your chosen platform.

GTM (Google Tag Manager)

// Create Pageview
dataLayer.push({
    ‘event’: ‘VirtualPageview’,
    ‘virtualPageURL’: ‘/sponsor/confirmation/{donation reference}’
});

// E-commerce data
dataLayer = [{
    ‘ecommerce’: {
    ‘currencyCode’:'{donation currency}’,
    ‘purchase’ : {
       ‘actionField’: {
          ‘id’: ‘{donation id}’,
          ‘revenue’: ‘{donation amount}’,
          ‘type’: ‘{donation type e.g. personal vs online}’,
          ‘payment_method’: ‘{payment method}’,
          ‘po_number’: ‘{PO number}’,
          ‘tax_ref’: ‘{payment gateway reference}’
       },
       ‘products’: [{
          ‘name’: ‘{fundraiser or team name}’,
          ‘id’: ‘[Event Code or DIY theme]’,
          ‘price’: ‘{donation amount}’,
          ‘category’: ‘Sponsored Donation’,
          ‘quantity’: 1,
       }]
    }
}
}];

// event
dataLayer.push({
    ‘event’: ‘donation’
    ‘eventMeta’: ‘Sponsored Donation’,
    ‘eventCode’: ‘[Event Code or DIY theme]’,
});

GA (Standard Google Analytics)

// pageview
ga(‘send’,’pageview’,’/sponsor/confirmation/{donation reference}’);

// event
ga(‘send’,’event’,’donation’,’Sponsored Donation,'[Event Code]’);

// e-commerce
ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘{donation id}’,
‘affiliation’: ”,
‘revenue’: ‘{donation amount}’,
‘shipping’: ‘0’,
‘tax’: ‘0’
});

ga(‘ecommerce:addItem’, {
‘id’: ‘[Event Code or DIY theme]’,
‘name’: ‘{fundraiser or team name}”,
‘category’: ‘Sponsored Donation’,
‘price’: ‘{donation amount}’,
‘quantity’: ‘1’,
});
ga(‘ecommerce:send’);

GTAG

// event
gtag(‘event’, ‘donation’, { “type”: “Sponsored Donation” });

// e-commerce
gtag(‘event’, ‘purchase’, {
“transaction_id”: “{donation id}”,
“value”: {donation amount},
“currency”: “{donation currency}”,
“tax”: 0,
“shipping”: 0,
“items”: [
{
“id”: “[Event Code or DIY theme]”,
“name”: “{fundraiser or team name}”,
‘category’: ‘Sponsored Donation’,
“list_name”: “{event code or DIY theme}”,
“quantity”: 1,
“price”: ‘{donation amount}’,
},
]
});

FB (Facebook Pixel)

fbq(‘trackCustom’, ‘sponsored donation’, {});
fbq(‘track’, ‘Purchase’, {value: ‘{donation amount}’, currency: ‘{donation currency}’});




Non-Sponsored Donations (Generic Donations)

Non-Sponsored donations are donations made to a generic dontion / crowdfunding page. All successful non-sponsored donations will have the following data sent to your chosen platform.

GTM (Google Tag Manager)

// e-commerce
dataLayer = [{
 ‘ecommerce’: {
 ‘currencyCode’:'{donation currency}’,
 ‘purchase’ : {
    ‘actionField’: {
       ‘id’: ‘{donation id}’,
       ‘revenue’: ‘{donation amount}’,
       ‘payment_method’: ‘{payment method}’,
       ‘po_number’: ‘{po number}’,
       ‘frequency’: ‘{donation frequency e.g. weekly, monthly, yearly, one-off}’,
       ‘type’: ‘{donation type e.g. recurring vs one-off}’

    },
    ‘products’: [{
       ‘name’: ‘{page name}’,
       ‘id’: ‘{page id}’,
       ‘price’: ‘{donation amount}’,
       ‘category’: ‘Recurring Donation or Donation’,
       ‘quantity’: 1,
      
}]
    }
}
}];

// event
dataLayer.push({
‘event’: ‘donation’,
‘eventMeta’: ‘Recurring Donation or Donation’
});

GA (Standard Google Analytics)

// event
ga(‘send’,’event’,’donation’,’donated’);

// e-commerce
ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
    ‘id’: ‘{donation id}’,
    ‘affiliation’: ”,
    ‘revenue’: ‘{donation amount}’,
    ‘shipping’: ‘0’,
    ‘tax’: ‘0’
});
ga(‘ecommerce:addItem’, {
    ‘id’: ‘{page id}’,
    ‘name’: ‘{page name}’,
    ‘category’: ‘recurring donation or donation’,
    ‘price’: ‘{donation amount}’,
    ‘quantity’: ‘1’,
});
ga(‘ecommerce:send’);

GTAG

// event
gtag(‘event’, ‘donated’, { “type”: “donation” });

// e-commerce
gtag(‘event’, ‘purchase’, {

 “transaction_id”: “{donation id}”,
 “value”: {donation amount},
 “currency”: “{donation currency}”,
 “tax”: 0,
 “shipping”: 0,
 “items”: [
{
 “id”: “{page id}”,
 “name”: “{page name}”,
 ‘category’: ‘recurring donation or donation’,
 “quantity”: 1,
 “price”: ‘{donation amount}’,
},
]
});

FB (Facebook pixel)

fbq(‘trackCustom’, ‘donation’, {});
fbq(‘track’, ‘Purchase’, {value: ‘{donation amount}’, currency: ‘{donation currency}’});

 

Event Registrations

On successful entry to an event the following data will be sent to your chosen platform.

GTM (Google Tag Manager)

// e-commerce data
dataLayer = [{
  ‘ecommerce’: {
  ‘currencyCode’:'{currency}’,
  ‘purchase’ : {
  ‘actionField’: {
     ‘id’: ‘{transaction id}’,
     ‘revenue’: ‘{total paid}’,
     ‘type’: ‘{event type e.g. offline vs online}’

  },
‘products’: [{
    ‘name’: ‘{event code}
    ‘id’: ‘{transaction id}’,
    ‘price’: ‘{entry fee}’,
    ‘category’: ‘Registration’,
    ‘sku’: ‘[Event Code]’
    ‘quantity’:’1′
 }
 // optional donation
 ,{
    ‘name’: ‘{event code}’,
    ‘price’: ‘{personal donation amount}’,
    ‘category’: ‘Personal Donation’,
    ‘sku’: ‘[Event Code]’
    ‘quantity’:’1′
    }
]
}
}
}];

// Event
dataLayer.push({
    ‘event’: ‘registration’,
    ‘eventMeta’: ‘Online/Offline Registration’,
   
‘eventCode’: ‘[Event Code]’,
});

// optional donation
dataLayer.push({
    ‘event’: ‘donation’,
    ‘eventMeta’: ‘Personal Donation’,
   
‘eventCode’: ‘[Event Code]’,
});

// Pageview
dataLayer.push({
    ‘event’: ‘VirtualPageview’,
    ‘virtualPageURL’: ‘/register/eventconfirmation/{event_key}/{confirmation_key}’
});

GA (Google Analytics)

// event
ga(‘send’,’event’,’registration’,’registered’,'[event key]’);

     //pageview for desktop
     ga(‘send’,’pageview’,’/register/eventconfirmation/{event_code}/{confirmation_key}’);

// personal donation
ga(‘send’,’event’,’personal-donation’,’donated’,'[event code]’);

//e-commerce
ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
    ‘id’: ‘{transaction id}’,
    ‘affiliation’: ”,
    ‘revenue’: ‘{total paid}’,
    ‘shipping’: ‘0’,
    ‘tax’: ‘0’
});

   // entry fee
    ga(‘ecommerce:addItem’, {
       ‘id’: ‘{transaction id}’,
       ‘name’: ‘{event code}’,
       ‘sku’: ‘[Event Code]’
       ‘category’: ‘Registration’,
       ‘price’: ‘{entry fee}’,
        ‘quantity’: ‘1’
    });

// donation
ga(‘ecommerce:addItem’, {
‘id’: ‘{transaction id}’,
‘name’: ‘{event code}’,
‘sku’: ‘[Event Code]’
‘category’: ‘Personal Donation’,
‘price’: ‘{personal donation amount}’,
‘quantity’: ‘1’
});
ga(‘ecommerce:send’);

GTAG

// event
gtag(‘event’, ‘registered’, { “type”: “Registration” });

// e-commerce
gtag(‘event’, ‘purchase’, {
 “transaction_id”: “{transaction id}”,
 “value”:{total paid},
 “currency”: “{currency}”,
 “tax”: 0,
 “shipping”: 0,
 “items”: [
{
 “id”: “1234”,
 “name”: “Registration”,
 “category”: “{event code}”,
 “quantity”: 1,
 “price”: ‘{entry fee}’
},
{
 “id”: “1234”,
 “name”: “Personal Donation”,
 “quantity”: 1,
 “price”: ‘{personal donation amount}’,
 “category”: “{event code}”,
‘sku’: ‘[Event Code]’

},
]
});

FB (Facebook Pixel)

fbq(‘track’, ‘CompleteRegistration’, {content_name:{event_name},content_category:{DIY or Event}});
fbq(‘track’, ‘Purchase’, {value: ‘{total paid}’, currency: ‘{currency}’});

Shop Purchases

On successful checkot the following will be sent to your chosen platform.

GTM (Google Tag Manager)

// e-commerce data
dataLayer = [{
‘ecommerce’: {
‘currencyCode’:'{currency}’,
‘purchase’ : {
‘actionField’: {
    ‘id’: ‘{transaction id}’,
    ‘revenue’: ‘{total paid}’,
    ‘type’: ‘sale’,
    ‘payment_method’: ‘{payment method}’,
    ‘po_number’: ‘{PO number}’

},
‘products’: [{
    ‘name’: ‘{product name}
    ‘id’: ‘{product id}’,
    ‘price’: ‘{sub total}’,
    ‘category’: ‘Merchandise’,
    ‘quantity’:’1′
}
// optional donation
,{
‘name’: ‘Personal Donation’,
    ‘price’: ‘{personal donation amount}’,
    ‘category’: ‘Personal Donation’,
    ‘quantity’:'{quantity}'
}
]
}
}
}];

// Event
dataLayer.push({
‘event’: ‘sale’,
‘eventMeta’: ‘shop sale’,
});

GA (Google Analytics)

//e-commerce
ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
‘id’: ‘{transaction id}’,
‘affiliation’: ”,
‘revenue’: ‘{total paid}’,
‘shipping’: ‘0’,
‘tax’: ‘0’
});

// for each item
ga(‘ecommerce:addItem’, {
‘id’: ‘{product id}’,
‘name’: ‘{product name}’,
‘category’: ‘Merchandise’,
‘price’: ‘{sub total}’,
‘quantity’: ‘{quantity}’
});

// donation
ga(‘ecommerce:addItem’, {
‘id’: ‘{transaction id}’,
‘name’: ‘{event code}’,
‘sku’: ‘[Event Code]’
‘category’: ‘Personal Donation’,
‘price’: ‘{personal donation amount}’,
‘quantity’: ‘1’
});
ga(‘ecommerce:send’);

GTAG

// e-commerce
gtag(‘event’, ‘purchase’, {
 “transaction_id”: “{transaction id}”,
 “value”:{total paid},
 “currency”: “{currency}”,
 “tax”: 0,
 “shipping”: 0,
 “items”: [
{
 “id”: “{product id}”,
 “name”: “{product name}”,
 “category”: “Merchandise”,
 “quantity”: {quantity},
 “price”: ‘{sub total}’
},
{
 “id”: “1234”,
 “name”: “Personal Donation”,
 “quantity”: 1,
 “price”: ‘{personal donation amount}’,
 “category”: “Personal Donation”,
},
]
});

FB (Facebook Pixel)

fbq(‘track’, ‘Purchase’, {value: ‘{total paid}’, currency: ‘{currency}’});

URL Based Tracking

In addition to the event and e-commerce data that we send through, you can also setup your own funnels and goals for various activity types on your site. The urls for each “journey” can be found within your platform when editing events, however below is a list of confirmation page urls that can be used.

Sponsored Donations

https://yoursite.com/fundraiser/{fundraiser_name}
https://yoursite.com/sponsor/processpayment
https://yoursite.com/sponsor/confirmation/{random_string} (Pseudo pageview)

Generic Donations

https://yoursite.com/{page_name}
https://yoursite.com/processdonation
https://yoursite.com/processdonation/confirmation/{page_name} or
custom url

Online Event Registrations

https://yoursite.com/register/{event_code}/{optional_form_code}
https://yoursite.com/register/fundraising/{event_code}
https://yoursite.com/register/merchandise/{event_code}
https://yoursite.com/register/teamdetails/{event_code}
https://yoursite.com/register/entries/{event_code}
https://yoursite.com/register/waves/{event_code}
https://yoursite.com/register/pay/{event_code}
https://yoursite.com/register/eventconfirmation/{event_code}/{random_string} or
custom url

Offline Event Registrations

https://yoursite.com/event/register/{event_code} or
https://yoursite.com/event/tickets/{event_code} or
https://yoursite.com/event/rsvp/{event_code}

If you’d like further help please pop in a support ticket from your Funraisin admin and our team will assist you.