A site I'm building has a requirement to track the sign-ups that occur from various landing pages. Using referral.module, I can facilitate this by ensuring that there is a different user that is associated with each of the landing pages. It's a little hacky, but it works.

However, what do you think about allowing drupal admins to spin-up "userless" referral links? The links could probably contain keys that the user defines, rather than the hex code that currently gets created for user referrals.

Your module names itself "User Referral", but it's really just called "referral", so it might fit in nicely :-).

WDYT?

Comments

kbahey’s picture

We do keep currently the information about URLs in the database (http_referrer), so we could use that I suppose.

We could add code to check in referral_get() to check if _referral_ref2uid() returns false, and then record in the cookie that the referring user is 0 (no body), and voila, you get what you want. No need for userless referral links as you call them.

Perhaps we should make that an option in the settings, so users are not confused by it being on by default.

ryan_courtnage’s picture

I like where you are going with this. The current problem I see is that http_referrer does not exist if a user hits the referral url directly, as they might if the link was emailed or otherwise given to them.

Perhaps it's worthwhile storing REQUEST_URI, or even just the referral code that was used [arg(1)]?

kbahey’s picture

In the event we do not have a referral link, nor an http referrer, we record nothing, simply because there is nothing to record.

Meaning, if we have no valid referral link, nor a valid http referer, then we should not record a referral event.

We are no worse off than we are today.

kbahey’s picture

Version: master » 6.x-1.x-dev
ryan_courtnage’s picture

Right, but suppose we went ahead and changed _referral_ref2uid() to set the referring uid to 0 when no valid referral id is found. A site owner then distributes 2 links that I want to track signups from:

referral/canadians-rule
referral/americans-rule

Any referrals generated would be stored as being from referral_uid 0. However, there is no context around the referrals - no way to know if canadians or americans rule more...

Another problem might be that some script kiddies might start hitting referral/aussies-rule, which I do not want to track referrals for. So there would probably need to be some place where the admin has defined what the valid "userless" referral links are.

hmmm

kbahey’s picture

My "solution" depends on NOT modifying ref2uid, and letting it return FALSE if the referral URL cannot be decoded as a valid hex code that has an underlying UID in it.

In this case, we just use the http referer.

The module's design depends on calculated hex code. Introducing something else needs a redesign.

If the above outline is not enough to satisfy the requirements for your case, then it needs to rethought.

ryan_courtnage’s picture

Ya, I'm not so sure that using the http_referrer would work for my case. In my case the admin would probably have to pre-define URLs to track signups from. Since it would need it's own table, an addition like this might be best to implement as a new module that depends on referral.module, and hooks into it's tracking magic at various places.

kbahey’s picture

If we can make referral more of an api with other modules hooking on to it, that would be a big advantage, since it would open the api for many other things.

The current "user" referral would be one implementation, tracking users via a hex code.

Tracking pages would be another.

...etc.