Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Show modules based on referrer
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 */
}
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
- Index
- » MetaMod
- » MetaMod General Support
- » Show modules based on referrer
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7660
- Newest User:
- marino9885
- Members Online:
- 0
- Guests Online:
- 184
- 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