How to create an Affiliate or Referral link - that lasts?

jasmin

New Member
I have managed to create an affiliate link, that adds the referrer ID into the form.

BUT, if the visitor leaves the page and comes back, or even visits another page and comes back to the form, the referrer information IS LOST.

How can we create a way where the referrer info is remembered between page views and even visits?

I guess this can be done with Session information or cookies. However I don't have an idea how that would be implemented.

Is there any beautiful soul out there that has any idea how to make the referrer id last through sessions and browsing pages?

---
For those also interested in creating a referral link, I give away the code that I have managed to create so far here, that works if they fill in the form directly when visiting...

http://fabrikar.com/forums/index.ph...al-id-from-url-between-pages-and-forms.50830/
 
Just so I understand the flow ...

The affiliate link points to a Fabrik registration form, with the query string arg that you use for the element default. But it's possible the user may not submit the form at the point, and may browse other pages on the site, before coming back to the registration form.

In that case, something like this should work for the element default:

Code:
$app = JFactory::getApplication();
$session = JFactory::getSession();
$ref = $app->getString('ref', '');

if (empty($ref)) {
   // if no ref query string, get it from session, use something unique (not just 'ref')
   $ref = $session->get('fabrik.custom.ref', '');
}
else {
  // if ref in query string, store it in session in case they don't submit the form right away
   $session->set('fabrik.custom.ref', $ref);
}

return $ref;

-- hugh
 
I made a modification to your code and got it to work! :)

I isolated that problem was your line:
$ref = $app->getString('ref', '');

that made the whole site not render anymore, except these error messages:
0 Call to undefined method Joomla\CMS\Application\SiteApplication::getString()
0 Call to a member function getString() on null

So I placed my old code back instead of that line and then it worked perfectly:
$ref= $link->input->getString('ref');

Do you think it is totally ok?

Anyway, I can now visit other pages or even close the whole tab, and then come back to the site and magically, the Referrer ID is filled in the form!

Thank you very much for the help cheesegrits. You are genious! :)

---

But what about when the Session expires?

Can there be a cookie solution so if they come back weeks later and register, the REF is back again?
 
Oh, yeah, it should have been $app->input->getString().

You can use $list for the variable name if you want, but everywhere else in pretty much any code ever written for Joomla, you assign getApplication() to a variable called $app. Then later in the code when you see the $app variable, you know it's the application.

-- hugh
 
Ok. Thanks! :)

How about the last question? Any ideas there?

Q: What about when the Session expires?
Can there be a cookie solution so if they come back weeks later and register, the REF is back again?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top