# Custom placeholder (macro)
Store placeholder (macros) scripts in /var/www/keitaro/application/macros/
.
# How to create a placeholder
Let's implement a placeholder {randomx:min,max}
that returns a random number between min
and max
.
Create a new file /var/www/keitaro/application/macros/randomx.php
with code:
<?php
namespace Macros;
use Traffic\Model\Stream;
use Traffic\RawClick;
use Traffic\Macros\AbstractClickMacro;
class randomx extends AbstractClickMacro
{
public function process(?Stream $stream, RawClick $click, $min, $max)
{
return rand($min, $max);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
See also:
# How to create S2S placeholder
Use AbstractConversionMacro
instead of AbstractClickMacro. Example:
<?php
namespace Macros;
use Traffic\Model\Stream;
use Traffic\Model\Conversion;
use Traffic\Macros\AbstractConversionMacro;
class randomx extends AbstractConversionMacro
{
public function process(?Stream $stream, Conversion $click, $min, $max)
{
return rand($min, $max);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Read also about AbstractConversionMacro.