File tree 2 files changed +40
-2
lines changed
2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,19 @@ final class Custom extends Parameters
34
34
35
35
public ?float $ value = null ;
36
36
37
+ /**
38
+ * This holds an array of custom properties. See https://developers.facebook.com/docs/meta-pixel/implementation/conversion-tracking#custom-properties
39
+ *
40
+ * NOTICE that if you define a custom property with the same name as any of the standard properties, your
41
+ * custom property will be overridden by the value of the standard property
42
+ *
43
+ * @var array<string, mixed>
44
+ */
45
+ public array $ customProperties = [];
46
+
37
47
protected function getMapping (): array
38
48
{
39
- return [
49
+ return array_merge ( $ this -> customProperties , [
40
50
'content_category ' => $ this ->contentCategory ,
41
51
'content_ids ' => $ this ->contentIds ,
42
52
'content_name ' => $ this ->contentName ,
@@ -50,7 +60,7 @@ protected function getMapping(): array
50
60
'search_string ' => $ this ->searchString ,
51
61
'status ' => $ this ->status ,
52
62
'value ' => $ this ->value ,
53
- ];
63
+ ]) ;
54
64
}
55
65
56
66
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Setono \MetaConversionsApi \Event ;
6
+
7
+ use PHPUnit \Framework \TestCase ;
8
+
9
+ /**
10
+ * @covers \Setono\MetaConversionsApi\Event\Custom
11
+ */
12
+ final class CustomTest extends TestCase
13
+ {
14
+ /**
15
+ * @test
16
+ */
17
+ public function it_generates_payload (): void
18
+ {
19
+ $ user = new Custom ();
20
+ $ user ->currency = 'DKK ' ;
21
+ $ user ->customProperties ['my_custom_property ' ] = 'test ' ;
22
+
23
+ self ::assertEquals ([
24
+ 'currency ' => 'dkk ' ,
25
+ 'my_custom_property ' => 'test ' ,
26
+ ], $ user ->getPayload ());
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments