# Custom macro script


Available only in Professional and Business licenses

# How to create a macro script

Directory for macro scripts /application/macros/.

To add new macro, we'll create a file /application/macros/randomx.php with code:

namespace Macros;

use Traffic\Model\BaseStream;
use Traffic\RawClick;
use Traffic\Macros\AbstractClickMacro;

class randomx extends AbstractClickMacro
    public function process(?BaseStream $stream, RawClick $click, $min, $max)
        return rand($min, $max);

Make sure that class name and file name are the same.

In order to send parameters to macro script, just specify in macro:

{random:100,999} It will send $min = 100 and $max = 999

To read more about $stream and $rawClick read page Internals.

# How to get request params?

$this->getServerRequest() returns object of class PSR-7 ServerRequest.