Actions (Redirects)

List of actions

  • HTTP redirect — sends status “302 Moved Temporarily” (the most common redirect)
  • JS redirect — executes JS code with redirect
  • Meta redirect — redirect that uses META tag
  • Redirect with blank referrer — executes JS code that clear referrer
  • Open in frame — generates tag frameset and load page in it
  • Open by CURL — downloads page by CURL library and shows to browser
  • 404 Not Found — whos blank page with HTTP status “404 Not Found”
  • Send to Campaign — sends to another campaign
  • Send to Stream - sends to another stream
  • Show text — shows text
  • Show as HTML-page — generates HTML page with content in <body>
  • REMOTE — request page and execute redirect to URL that the page contains
  • FormSubmit — shows HTML form with POST method and automatically submit it.
  • Redirect for iframe — executes redirect when TDS loaded in <iframe>
  • Redirect for Script — executes redirect when TDS loaded in <script>
  • SubId — shows subid (is used in tracking mode)

How actions work in various cases

Action Link Script
HTTP redirect Redirect Executes JS code Redirect in frame
JS redirect Redirect Doesn't work Redirect in frame
Meta redirect Redirect Redirect Redirect in frame
Double meta redirect Redirect Redirect Redirect in frame
Redirect with blank referrer Redirect Doesn't work Redirect in frame
Open in frame Shows frame Doesn't work Frame in frame
CURL Shows page Executes JS code Page in frame
404 NotFound Page 404 Nothing Empty frame
Show text Shows text Executes JS code Text in frame
Show HTML Shows page Doesn't work Page in frame
REMOTE Redirect Executes JS code Redirect in frame
FormSubmit Redirect Doesn't work Redirect in frame
Redirect for iframe Doesn't work Doesn't work Redirect
Redirect for script Doesn't work Redirect Doesn't work
SubId Shows subid Doesn't work SubId in frame

How to hide source of traffic?

Read on page How to Hide Referrer.

Which redirect should I use to avoid a ban of website?

The safest redirect is iframe/script redirect and besides you can send a request straight to API. But there is no absolute protection against the sanctions of search engines.

Create a redirect

We will create a new sample redirect through Meta Refresh. Create the file /application/redirects/meta.php. File name should be the same as class name, but without “_redirect”.

<?php
/**
 * @redirectName Meta
 * @redirectWeight 100
 */
use \Models\Stream;
use \Models\Visitor;
class meta_redirect extends BaseRedirect
{
	public function execute(Stream $stream, Visitor $visitor)
	{
                $code = '<html>
                <head><meta http-equiv="REFRESH" content="1; URL=\'#url#\'"></head>
                <body>
                  The Document has moved <a href="#url#">here</a>
                </body>
                </html>';
 
                $code = str_replace('#code#', $stream->getUrlWithParams($visitor), $code);
		$this->setContent($code);
	}
 
	public function debugExecute(Stream $stream, Visitor $visitor)
	{	
		return 'Meta: ' . $stream->getUrlWithParams($visitor);
	}
 
        public function decorate(Stream $stream)
        {
               return 'Meta' . $stream->getUrl();
        }
}

Template

<?php
/**
 * @redirectName New redirect
 * @redirectWeight 100
 */
use \Models\Stream;
use \Models\Visitor;
class myredirect_redirect extends BaseRedirect
{
    // Redirect or action execution method
    public function execute(Stream $stream, Visitor $visitor) 
    {
        // Redirect algorithm is placed here, php-code
    }
 
    // Redirect or action executing in debugging mode
    public function debugExecute(Stream $stream, Visitor $visitor)
    {	
         return "Redirecting to: " . $stream->getUrlWithParams($visitor);	
    }	
 
    public function decorate(Stream $stream)
    {
         return 'MyRedirect' . $stream->getUrl();
    }
}

Do not use header() function in your code, call it through $this->addHeader('...').

Methods available in redirect code

  • $this->addHeader($string) — add a line to http-header;
  • $this->setContent($string) — display text;

Which methods are available for $stream и $visitor?

Read the sections Methods Visitor, Methods Stream.

How to install redirect script?

Upload it to the directory application/redirects.

How to add the remarketing or metric code?

You need to create script of the redirect based of existing one: js.php, frame.php, formsubmit.php.

Consider the example of adding FaceBook pixel.

Create a file application/redrects/remarketing.php. With code:

<?php
/**
 * @redirectName REMARKETING
 * @redirectWeight 2
 */
use Models\Stream;
use Models\Visitor;
class remarketing_redirect extends BaseRedirect
{
  public function execute(Stream $stream, Visitor $visitor)
  {
    $this->setContent($this->_getJavascriptRedirect($stream, $visitor));
  }
 
  public function debugExecute(Stream $stream, Visitor $visitor)
  { 
    return 'REMARKETING: ' . $stream->getUrlWithParams($visitor);
  }
 
  public function decorate(Stream $stream)
  {
    return 'REMARKETING: ' . $stream->getUrl();
  }
 
  private function _getJavascriptRedirect(Stream $stream, Visitor $visitor)
  {
    $remarketing = <<<EOF
    <!-- Код ремаркетинга -- >
 
    <!-- Facebook Pixel Code -->
    <script>
    !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
    n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
    n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
    t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
    document,'script','https://connect.facebook.net/en_US/fbevents.js');
 
    fbq('init', '1914721942087471');
    fbq('track', "PageView");</script>
    <noscript><img height="1" width="1" style="display:none"
    src="https://www.facebook.com/tr?id=1914721942087472&ev=PageView&noscript=1"
    /></noscript>
    <!-- End Facebook Pixel Code -->
EOF;
 
    $code = '<html>
    <head>
        ' . $remarketing . '
        <meta http-equiv="REFRESH" content="1; URL=\'' . $stream->getUrlWithParams($visitor) . '\'">            
        <script type="text/javascript">window.location = "' . $stream->getUrlWithParams($visitor) . '";</script>
    </head>
    <body>
        The Document has moved <a href="' . $stream->getUrlWithParams($visitor) . '">here</a>
    </body>
    </html>';
 
    return $code ;
  }
}

Edit the file application/redirects/remote.php.

Set a necessary value at the line:

protected $_ttl = 60

Save the file and set 666 attributes for it then it will not be overwritten during an update.

Response format for REMOTE action

The full code:

http://domain.com/page

or a domain

domain2.com

Script rotator for REMOTE

<?php
if (!file_exists('./links.txt')) {
    die('No file links.txt');
}
$content = file_get_contents('./links.txt');
$lines = explode("\n", $content);
$links = array_map(function($line){
  $line = trim($line);
  return empty($line) ? null : $line;
}, $lines);
$links = array_filter($links);
echo $links[rand(0, count($links)-1)];
?>

Create a file links.txt at the script directory with a list of links, one link per line.