Referral Sources

Contrib type: 
Module
Status: 
Complete and working
Moderation: 
Awaiting moderation
Latest version: 
6.x-1.0

Downloads

Compatibility: 
Ubercart 2.x

This module is now released on Drupal.org (http://drupal.org/project/referralsources). All issues in this thread should be resolved. Please file any bug reports or feature requests using the project issue tracker on Drupal.org.

The Referral Sources module allows you to ask your users "Where did you hear about us?" anywhere on your site, and track that data in a central location. It provides a admin interface for creating referral sources that users can select from a list, and a page where you can view statistics on referral source selections. Referral source submissions are stored in a single table, no matter where they came from, making it easy to track submissions and create reports based on that data.

The core Referral Sources module allows you to easily embed a referral source selection to the user registration page, or your own custom forms and modules.

The Referral Sources (Ubercart) module adds a checkout pane prompting users to specify a referral source, and a order pane so you can view referral sources selected on when viewing individual orders.

The Referral Sources (Webform) module adds support for embedding the referral sources selection in any webform.

The Referral Sources (Example) module demonstrates how you can add the referral source selection to your own forms and modules.

Dependencies:
* The Referral Sources (Ubercart) module requires Ubercart.
* The Referral Sources (Webform) module requires the Webform module.

See included README.txt for full installation and configuration instructions.


adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Referral Sources

The original upload had some potential security issues. All of these issues should be fixed now. I've updated the attached file with the latest version.

mkrapf's picture
Offline
Joined: 04/13/2009
Juice: 34
Keep getting an error

I get this error when trying to add a referral source

user warning: Unknown column 'grouping' in 'field list' query: UPDATE referralsources SET code = '1234', title = 'email', grouping = '', description = '', weight = 0 WHERE rid = 0 in C:\wamp\www\drupal9\sites\all\modules\referralsources\referralsources.admin.inc on line 446.

Any help would be appreciated.

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Sorry about that...

Apparently while developing the module I added the grouping field to the referralsources table by hand and it never got into the schema.

It's fixed in the updated zip. Just install it and run update.php and everything should be fine. Let me know if you have any other issues.

gbuyers's picture
Offline
Joined: 07/16/2009
Juice: 5
update zip

Great Contrib... I am also getting the same error and I don't see the update zip attached.

Thanks in advance.

-Nevermind, I manually added the grouping field to the referralsources table and it worked GREAT!

Thanks!!!

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: update zip

I just replaced the zip that was there. Sorry for the confusion. I have a CVS account now so I'll have this on drupal.org soon.

martinjbaker@drupal.org's picture
Offline
Joined: 07/27/2009
Juice: 23
Any way to not have options grouped?

Thanks for the module, looks very useful.

I've entered 5 sources (leaving the grouping field empty for each one) but they seem to be grouped under "Other" which is a bit confusing.

So I get this:

---------
Please select one...
Other
A Friend
This magazine
That magazine
Another magazine
Other (please specify below)
---------

when I'd prefer to have the simpler:

---------
Please select one...
A Friend
This magazine
That magazine
Another magazine
Other (please specify below)
---------

with no grouping at all. Is there any way to do this?

Also it would be great to have Referral Sources available as a block - I'd prefer to add it to the cart/checkout/complete page rather the cart/checkout page.

thanks

Martin

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Any way to not have options grouped?

I meant to make grouping optional but apparently I didn't get that far in this version. I will make it optional in the next version, and see about making a Referral Sources block.

Thanks,
Adam

amitkarpe's picture
Offline
Joined: 08/03/2009
Juice: 9
Porrting for Ubercart 1.x

Dose any one ported this module to Ubercart 1.x / Drupal 5 ?

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Porrting for Ubercart 1.x

I won't be backporting this to UC1/D5. Anyone else is welcome to and I'll add the port here and on the D.O project page (when I finally get around to setting it up).

thetoast's picture
Offline
Joined: 07/30/2009
Juice: 30
thanks

Was just about to write my own module to do this but you already had, just wanted to say a huge thanks for creating this module. It works really well. I've only used it so far for ubercart and hopefully I'll find a scenario where I can use the module in the other possible ways. Thanks again Smiling

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: thanks

Glad to hear you found it useful. Smiling There are a lot of improvements I want to make. Let me know if you have any suggestions. I'm busy with another project right now, but I will be getting back to this soon.

Scott M. Sanders's picture
Offline
Joined: 04/24/2009
Juice: 326
Complicated

This seems like a rather complex module when I can just add a field via user management > profiles that users can complete on registration.

I like that this will show up anywhere and record stats but has a kinda steep learning curve to it really, especially on a project deadline. Nice idea though.

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Complicated

If you only ever want to ask for that information in one place, then yes, do that.

If you might some day want to ask for that information at different areas of your site, then you might want to take another look at it.

Doing what you want with this module is fairly simple:
1) Enable Referral Sources module.
2) Go to Content Management -> Referral Sources.
3) Click Add.
4) Fill out fields, click Save. Repeat for each referral source you want to track.

Referral source selection at user registration is enabled by default. You don't have to do anything else unless you want to.

thetoast's picture
Offline
Joined: 07/30/2009
Juice: 30
Re: Complicated

I was on a project deadline when I needed to implement something like this, so this module was a big help. Also, you say you can just add a field the user can complete on registration, sounds simple enough, but what about analysing those stats?

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Re: Complicated

Users in roles with the "view referral source statistics" permission will be able to
view the Referral Sources Statistics page in Content Management. Administration -> Content Management -> Referral Sources -> Statistics.

It gives basic stats. Totals for each referral source selected/specified for the entire site and for each area where the referral sources prompt is shown. I might expand on this further but probably not too much unless someone comes up with a reporting API for Drupal. If you need to do something special with the data you could always write your own module to analyze it, or use some 3rd party reporting software like Crystal or Jasper to generate reports from the referralsources table.

thetoast's picture
Offline
Joined: 07/30/2009
Juice: 30
Re: Re: Re: Complicated

it's been a good solid month now since I've used this on our site, and the results have given us a good insight into how people are finding us, my only issue with the stats now that the data is coming in is not being able to break down the results further, for example, being able to show all the orders for a given option. I guess by allowing this it would make the module unique to ubercart and therefore not generic so it can be used any where on your site. If I get the time I'll try and write a patch with an option to allow breakdown reporting for ubercart. Apart from that module has been solid, good job dude Smiling

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Glad to hear it! Being

Glad to hear it! Smiling Being able to easily drill down and see exactly where the results came from would be a nice feature. I don't want to do any Ubercart-centric stuff in the main module... But if I allow sub-modules to render their own stats, then the Ubercart sub module (or any other) could easily add links to it's stats table that point to tables of orders (or any other data) for each referral source selection. I think I'm going to look into doing it this way, and implementing drill down for user registrations, Webform submissions, and generic FAPI form submissions as well as Ubercart. I've got another project I need to finish up before I can do this, but it's really, really close to being done. If you want to do up a patch in the meantime, feel free.

chadhester's picture
Offline
Joined: 05/12/2009
Juice: 54
Error in .module file

Using D6.14 and UC2.2:

I'm getting an error on the user registration and UC checkout page (when they are enabled):

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/MYDOMAINHERE.com/public_html/sites/all/modules/referralsources/referralsources.module on line 365.

Is anyone else experiencing this?

Regards,
Chad Hester

chadhester's picture
Offline
Joined: 05/12/2009
Juice: 54
CORRECTION

Okay, well, I'm not knowledgable enough to create a patch file, but here's the issue. The $options variable is NULL when there is nothing in the {referralsources} table. Not an issue if you have at least one option, but for completeness I'm providing a correction. Pretty easy to fix this. Here's the entire referralsources_select_options() function. The correction begins on line 362 with the "if($options !== null) {" statement.

<?php
/**
* Returns array of referral source options for select lists
*/
function referralsources_select_options($flat = FALSE) {
  static
$options;
  static
$options_flat;

  if (empty(

$options)) {
   
// Get referral sources from DB
   
$result = db_query("SELECT rid, title, grouping FROM {referralsources} ORDER BY weight asc");
    while (
$row = db_fetch_object($result)) {
     
// Create a grouped list of referral sources
     
if (!empty($row->grouping)) {
       
$options[$row->grouping][$row->rid] = $row->title;
      }
      else {
       
$options['Other'][$row->rid] = $row->title;
      }
    }
  }

  if (

$flat) {
   
// Remove grouping from options, reduce to key/value pairs (return array of valid options).
   
if (empty($options_flat)) {
      foreach (
$options as $k => $v) {
        if (
is_array($v)) {
          foreach (
$v as $k => $v) {
           
$options_flat[$k] = $v;
          }
        }
        else {
         
$options_flat[$k] = $v;
        }
      }
    }
   
$result = $options_flat;
  }
  else {
    if (
$options !== null) {
     
// Return grouped array of options for select list.
     
$result = $options;
     
// Add "Please select one..." option to beginning of select list.
     
$result = array_merge(array('' => array('' => t('Please select one...'))), $result);
     
// Add "Other" option to end of select list.
     
$result['Other']['OTHER'] = t('Other (please specify below)');
    } else {
     
$result = array();
    }
  }

  return

$result;
}

?>

Hope this helps someone.

Regards,
Chad Hester

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: CORRECTION

Thanks. I'll get that fixed.

DMSWebDesign's picture
Offline
Joined: 03/03/2010
Juice: 14
Issue with Referral Sources module (Ubercart)

I have installed Referral Sources module (Ubercart) on a site running php 5.2.11, Drupal V 6.16. I have set up a list of referral types, Each with a code number. This feature displays perfectly on the Ubercart checkout page, however, when I try to process the form I am getting this error:

user warning: Field 'title' doesn't have a default value query: INSERT INTO referralsources_submissions (rstid, order_id, uid, title, rid, other, created_datetime) VALUES ('referralsources_uc_order', 16, 5, 4, 'Evan Jones', '2010-03-20T12:11:55-07:00') in C:\Inetpub\wwwroot\sites\all\modules\referralsources\ubercart\referralsources_ubercart.module on line 89.

I made some changes to referralsources/ubercart.module line 89, but without resolving the problem. Can you please me correct code to repair this, or advise as to how to resolve this problem?

thank you,
Dawn

DawnShepherd@Cox.net

Uberchic's picture
Offline
Administrator
Joined: 08/29/2008
Juice: 754
Re: Issue with Referral Sources module (Ubercart)

As it says in the initial post "This module is now released on Drupal.org (http://drupal.org/project/referralsources). All issues in this thread should be resolved. Please file any bug reports or feature requests using the project issue tracker on Drupal.org."So, you should post your issue there.

adamo's picture
Offline
Getting busy with the Ubercode.
Joined: 02/17/2009
Juice: 229
Re: Issue with Referral Sources module (Ubercart)

Like Uberchic said, please post any issues at the official project page here: http://drupal.org/project/referralsources/. I can't promise I'm ever going to look at this page again.

It's odd that I don't see this error. Maybe it has something to do with the version of MySQL I'm running. The title field had the "not null" flag set but also had default value set to null. I would expect it to give me the same error you're getting, but it seems to implicitly convert the default null to an empty string on insert. I'll get this fixed in the next release. For now, just set the default value of the title column of the referralsources_submissions table to an empty string or unset the "not null" flag and it should work fine.