0

I'm developing a referral module that allows users to join a referral program.

Only visitors who come from a referral link AND have not visited the site before will be counted as referred user.

Is there any built-in Magento data to determine if user has been on the site before?

Otherwise, should I declare new session data for this purpose?

I suppose I must declare new session data, the get/set processes would be fired globally on every pages. How to reduce get/set processes? What is the best (better) practice of this purpose?

P/s: Answers with some code snippets are better but not required.

EDIT to make it clear: If a vistor has visited the site before by other ways (such as direct link, search engine,..), then visits the site again by a referral link, this user is NOT a referred user.

1 Answer 1

0

You could create a very simple/lightweight module for this. The idea is to have your referral links pointing to your custom controller. It would then capture the visitor's information (I think your best call here would be to capture the IP)

Then it would save this in a custom database table (ip, referral_link) should be enough. If you make both those fields unique, then it won't create duplicate data, you will have the exact number of referral users AND the code will only be executed once (when the user clicks on the link)

I won't post code snippets but I can give you more guidance if you need

2
  • First, thank you for checking question grammar for me. By now, I can capture vistor's info like you said. But theoretically, if a user has visited the site before (by other ways, such as direct link, search engine, ...), then visits the site again by a referral link, this use is NOT a referred user. I would only take a user who only knows (visits) the site from a referral link as a referred user. Aug 18, 2015 at 10:55
  • 1
    Set a cookie then. Then the same process applies then, when the user reaches the controller, make sure the cookie doesn't already exist Aug 18, 2015 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.