Custom Action/redirect Script

How to create a custom redirect script

All the redirect scripts must be located in /application/redirects/.

Let's create a script “FBPixel”. Create new file %%fbpixel.php with the code. Every time when you creating new scripts, make sure that class name and the file name are the same.

namespace Redirects;
use Traffic\Actions\AbstractAction;
class fbpixel extends AbstractAction
    protected $_name = 'FBPixel';     // action/redirect name
    protected $_weight = 100;
    public function getType()
        return self::TYPE_REDIRECT;              # or self::TYPE_OTHER
    protected function _execute()
         $remarketing = <<<EOF
    <!-- Facebook Pixel Code -->
    fbq('init', '1914721942087471');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none"
    <!-- End Facebook Pixel Code -->
    $url = $this->getActionPayload();
    $code = '<html>
        ' . $remarketing . '
        <meta http-equiv="REFRESH" content="1; URL=\'' . $url. '\'">            
        <script type="text/javascript">window.location = "' . $url . '";</script>
        The Document has moved <a href="' . $url . '">here</a>

Avaiable Methods

Method Description
$this->getRawClick() Get object RawClick
$this->getStream() Get object BaseStream
$this->getCampaign() Get object Campaign
$this->getLanding() Get object Landing
$this->getOffer() Get object Offer
$this->getServerRequest() Get object PSR-7 Server Request
$this->getActionPayload() Get action payload after macros are processed
$this->getRawActionPayload() Get action payload before macros are processed
$this->getActionOptions() Get action options
$this->addHeader($headerLine) Add header line to the response
$this->redirect($url) Perform redirect to an URL
$this->setContent($text) Send any content
$this->setContentType($contentType) Set HTTP content type
$this->setStatus($httpStatusCode) Send HTTP header status
$this->setDestinationInfo($string) Set value for “Destination” that you see in Click Log

How to Work With Multiple Integrations Methods ?

Check incoming parameter frm. Example:

switch ($this->getRequest()->getParam('frm')) {
   case 'script': 
   case 'frame':