Macros

How to use macros?

Add macro that you needed in URL of the stream. For example:

http://landing.com/search?q={keyword}

Macros list

  • {keyword} — keyword
  • {keyword:cp1251} — keyword with encoding
  • {ip} — IP address
  • {stream_id} — stream id
  • {referrer} — referrer
  • {country} — country code ISO-3166-1
  • {country_name:en} — country name (languages available: ru, en)
  • {region} — region code
  • {region_name:en} — region name (languages available: ru, en)
  • {city:en} — city name (languages available: ru, en)
  • {se_referrer} — search engine referrer
  • {date} — date
  • {date:YmdHis} — date in a certain format (http://php.net/manual/en/function.date.php)
  • {subid} — unique visitor subID. It is necessary for conversion tracking from partner pages
  • {source} — traffic source
  • {from_file:filename.txt} — insert the content of “filename.txt” file. File should be located in /var/macros/ directory.
  • {se} — search engine
  • {ua} — UserAgent
  • {device_type} — device type
  • {device_model} — device model
  • {operator} — carrier code
  • {operator_name:en} — carrier name (languages available: ru, en)
  • {sample:value1, value2, value3} — returns random value. You may use URLs: {_sample: http://site1.com, http://site2.com, http://site3.com}

GET-Parameters Macros

All the parameters transmitted to TDS are turned into macros. For example, if utm_source and utm_campaign were transmitted, the following macros are becoming available: {utm_source} и {utm_campaign}.

How to pass labels to a landing page from the source through TDS?

Add all labels to a campaign URL:

http://tds.com/campaign?utm_source=123&utm_term=444

At the streams the values of these labels can be substituted by the same name macros

http://landing.com/?utm_source={utm_source}&utm_term={utm_term}

Macros creation

For example, let us create a new macro whose output is a random number.

Create a new file /application/macros/random.php (file name should be related to class name, but without “_macros”).

Insert the code:

<?php
use Models\Stream;
use Models\Visitor;
 
class random_macros extends BaseMacros
{
    public function process(Stream $stream, Visitor $visitor, $min, $max)
    {
        return rand($min, $max);
    }
}

Class name random_macros is compiled from “random” file name and “_macros” addition. The class should contain process method with two variables $stream and $visitor. Additional variables are created after the previous two.

$min, $max values are transmitted using macros:

http://landing.com/{random:100,999} $min is equal to 100, $max to 999.

What kind of data can be taken from $stream and $visitor?