How to keep referral ID from URL between pages and forms?

jasmin

New Member
I need to track which user (affiliate) has referred another user with referral or affiliate links, that looks like this:

mydomain.com?ref=charlie
mydomain.com/register?ref=charlie

I have managed to GET the referral ID from the URLs above and place the ref ID in a form field, so that works. The working code is:

In the ELEMENT Default field, Eval = Yes

$link = JFactory::getApplication();
$ref= $link->input->getString('ref');
return $ref;

But if the visitor then visits other pages before signing up, the reference (referral ID) is lost, and not shown again on the pages that don't contain the last part ?ref=charlie.

How can the referral ID variable (charlie) be kept during the visit and when the visitor finally wants to register, the referral ID then magically appears in the form field again on any page on the site?

This code worked to insert the ref ID in the form field. But how is it then remembered for later? Does it have to do with SESSION and cookies or what?

---

I tried the following to store the refID to the Session and then hoping it would show up in the form on other pages, but didn't, the ref is lost. Don't know what to do from here!?

$link = JFactory::getApplication();
$ref= $link->input->getString('ref');

$_session = JFactory::getSession();
$_session->set('ref', '$ref');

$_session = JFactory::getSession();
$_session->get('ref');
return $ref;

---
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top