Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Show modules based on referrer

Show modules based on referrer

Please help,
I am trying to show specific modules based on the referrer.

The example I have tried below, is for the search term, 'Web Design Company Manchester'

I want to show a specific module based on the search term when the user comes from google.

My site is J2.5.7
Thanks,
Sean R.

/* detect if this user has already seen the module */
if (array_key_exists('DID_GOOGLE_MODULE', $_COOKIE)) return;

/* was the referer Google? */
if ( $core_genius->check( "referer starts with http://www.google.co.uk/#hl=en&outp … ster" )) {
  /* if so, set a cookie for 10 years... */
  setcookie('DID_GOOGLE_MODULE',1,time() + 10*365*24*60*60,'/');
  /* ... and show the module */
  return 266; /* replace XXX with module id to return */
}

reders
Beginner Modder
ranks
useravatar
Offline
12 Posts
Administrator has disabled public posting

Re: Show modules based on referrer

Hi Sean,

Unfortunately, these days Google has mostly moved to doing search with HTTPS which means (due to internet protocol) that the referrer string will often not show up on the site the user clicks on :-(

When a user does use http instead of https (e.g. when they do not have a google account or are not logged in to google), this should work:

if ( $core_genius->check( "referer starts with http://www.google/." )  // catch all permutations of Google
   and $core_genius->check( "referer contains any of q=web+design+company+manchester, q=web%20design%20company%20manchester" ) ) {
     return XXX;
}
// replace XXX with module id to show when that search is detected.


I put in checks for the "+" and "%20" versions, as on Chrome and Firefox I tested just now and it uses %20, while on Safari it seems to use "+".


Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Total Posts Today:
1
User Info:
 
Total Users:
10075
Newest User:
rsker57
Members Online:
0
Guests Online:
293

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked