Ok. The logic hook for CampaignLog doesnât work in your case. This is because the Tracker URL link hits the entry point âcampaign_trackerv2â.
The entry point is defined in include/MVC/Controller/entry_point_registry.php as:
'campaign_trackerv2' => array('file' => 'modules/Campaigns/Tracker.php', 'auth' => false),
Looking at Tracker.php I see the âhitsâ field is incremented by using pure SQL and not a SuiteCRM Bean. Therefore the inherited Bean logic hook âafter_saveâ will not be fired because the bean is not saving the recordâŚthe pure SQL is saving/updating the record.
So a logic hook will not work in this case.
You can intercept the incoming clicked link by creating a custom entry point named campaign_trackerv2. Notice the name is the same as the âstockâ entry point. If you define this entry point in custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php, your entry point will override the stock entry point.
So first you need to add something like this to custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php:
$entry_point_registry['campaign_trackerv2'] = array('file' => 'custom/modules/CampaignLog/trackeroverride.php', 'auth' => false);
You can then create custom/modules/CampaignLog/trackeroverride.php to utilize the $_REQUEST[âtrackâ] value. Use this value to look up the tracker URL record to see if it is one that you want to have special processing.
You could either copy the Tracker.php code or you might want to use require_once(âmodules/Campaigns/Tracker.phpâ) at the end of your trackeroverride.php. Either way, you insert you checks/logic in trackeroverride.php.
So trackeroverride.php might look like:
require_once('modules/Campaigns/utils.php');
$GLOBALS['log'] = LoggerManager::getLogger('Campaign Tracker v2');
$db = DBManagerFactory::getInstance();
if(empty($_REQUEST['track'])) {
$track = "";
} else {
$track = $_REQUEST['track'];
}
if(!empty($_REQUEST['identifier'])) {
$keys=log_campaign_activity($_REQUEST['identifier'],'link',true,$track);
}else{
//if this has no identifier, then this is a web/banner campaign
//pass in with id set to string 'BANNER'
$keys=log_campaign_activity('BANNER','link',true,$track);
}
$track = $db->quote($track);
if(preg_match('/^[0-9A-Za-z\-]*$/', $track))
{
$query = "SELECT tracker_url FROM campaign_trkrs WHERE id='$track'";
$res = $db->query($query);
$row = $db->fetchByAssoc($res);
// ADDED CODE
if ($row['tracker_url'] == 'http://suitecrm.com') {
// Do special processing....including updating LEAD records
}
$redirect_URL = $row['tracker_url'];
sugar_cleanup();
header("Location: $redirect_URL");
}
else
{
sugar_cleanup();
}
exit;
?>
Now your code is upgrade safe and the code should perform as before for all campaign trackers except for those that you code special logic.