courtly
courtly
courtly
courtly

Upcoming Events

San Francisco CiviCRM Meetup - February 8th, 2012
February 8th, 2012
Come meet others from the Bay Area who are interested in, using or developing (more...)

UK usergroup - London meetup
February 8th, 2012
Come and meet others from the UK that are using CiviCRM or are interested in (more...)

London user and administrator training
February 23rd, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM London sprint Feb 2012
February 27th, 2012
Following the CiviCRM training here in London, we will have a CiviCRM code (more...)

UK South West - CiviCRM Meetup
March 20th, 2012
Come meet others from the Area who are interested in, using or developing for (more...)

[Bristol, UK] user and administrator training
March 21st, 2012
A comprehensive hands on training course covering the configuration, (more...)

San Francisco user and administrator training
March 29th, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM Usability, Test and Code Sprint - San Francisco (March 2012)
March 29th, 2012
This usability, code and test sprint is targeted at CiviCRM users and (more...)

CiviCon 2012 San Francisco Bay Area - April 2nd 2012
April 2nd, 2012
CiviCon is THE annual event bringing together the people who use, develop, (more...)

CiviCRM Documentation, Test and Code Sprint - after CiviCon San Francisco (April 2012)
April 4th, 2012
This sprint is targeted at CiviCRM users and developers who want to work on (more...)

CiviCRM Components

Tools for engaging your supporters...

CiviContribute


CiviEvent


CiviMail


CiviMember


CiviReport


Tracking contributions and event registrations for campaigns and appeals

Not Just a Contact Database

These optional components give you more power to connect and engage your supporters.

  • civiCASE

  • Case management for clients and constituents.

  • civiEVENT

  • Online event registration and participant tracking.

  • civiMEMBER

  • Online signup and membership management.

  • civiMAIL

  • Personalized email blasts and newsletters.

  • civiREPORT

  • Report generation and template management.

May 16, 2009 - 21:15 — lobo

One of the common needs of a contribution or event registration system is to track what campaign that transaction is destined from and what link originated the transaction. This allows organizations to calculate what links / web sites / advertising / mailings are most effective and use that information to influence their current or future campaigns. Some organizations (e.g. wikimedia foundation) use a three level tracking scheme: Campaign, Appeal and Fund, while other organizations might choose to use only one tracking field.

This issue came up at the San Francisco developer camp. There is no built-in support for this in CiviContribute or CiviEvent. However we can accomplish something very similar using a combination of custom fields, populating fields via a GET url and a civicrm buildForm hook. We've made some changes to v2.2.4 to make it easier. Here is the recipe for tracking either a contribution or event registration page.

  1. Create a custom group called "Contribution Tracker" which extends Contribution. Within that group create three custom fields, one each for Campaign, Appeal and Fund. In my test setup i created these as searchable text fields with a length of 64 characters. Lets assume these custom fields have ids of 4, 5 and 6.
  2. Add these three fields to a Profile which is included on that contribution page. let assume the contribution page has an id of 1
  3. In a drupal module (lets call it civitracker) create the following hook
    function civitracker_civicrm_buildForm( $formName, &$form ) {
        // enable tracking feature
        if ( ( $formName == 'CRM_Contribute_Form_Contribution_Main' ||
               $formName == 'CRM_Contribute_Form_Contribution_Confirm' ||
               $formName == 'CRM_Contribute_Form_Contribution_ThankYou' ) &&
             $form->getVar( '_id' ) == 1 ) { // use  CONTRIBUTION PAGE ID here
    
            // use the custom field ID and custom field label here
            $trackingFields = array( 'custom_4' => 'Campaign',
                                                        'custom_5' => 'Appeal',
                                                        'custom_6' => 'Fund' );
            $form->assign( 'trackingFields', $trackingFields );
        }
    }
    
  4. Make sure your civitracker module is enabled

In the links that you add to your blog post or website, should pass in the values of the above three custom fields as GET parameters. Thus a sample URL would look like:

http://drupal.demo.civicrm.org/civicrm/contribute/transact?reset=1&id=1&custom_4=Campaign2009&custom_5=Summer&custom_6=General

CiviReport will ship a few reports that will analyze contributions based on Campaign, Appeal and Fund (these are being built for the Wikimedia Foundation). You can read more detailed specifications of the reports on the wiki. Some of the above changes are in v2.2.4. The issues that were filed (and fixed) to get the above working include:

Allow admins to track where contributions / event registrations are coming from via tracking codes
Allow contribution and event fields to set custom values via the URL

( categories: )

Comments

Got it working

To make it work for more than contribution page change:

$form->getVar( '_id' ) == 1 ) {

to

$form->getVar( '_id' ) >= 1 ) {

Hooks for contributions

Hooks for CiviContribute = Great!

Another great hook would be to enable rolling contributions that call a custom function/url at the specified intervals as specified in the setup of the contribution.

We have developed a Joomla! component to integrate with the payment gateway of Westpac, one of the major Australian banks, which records a CiviCRM Contribution upon success. The donation is a recurring contribution for a specified monthly amount, so it would be great if you could set up CiviContribute with a recurring contribution that would call a specified function/url at the given time through a cron job (with a token for the contribution id and contributor id that the receiving function could then use to talk with Civi through the API).

Andrew

Check the recurring payment paypal code ..

It basically records a new contribution and associates it with a recurring contribution based on information sent in by the payment processor

lobo

Thanks

Will do.