Skip to content

Commit

Permalink
Add: conversions api test code
Browse files Browse the repository at this point in the history
  • Loading branch information
jordyvanderhaegen committed Nov 18, 2021
1 parent a1482d2 commit db37aa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/conversions-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
return [
'access_token' => env('CONVERSIONS_API_ACCESS_TOKEN'),
'pixel_id' => env('CONVERSIONS_API_PIXEL_ID'),
'test_code' => null,
];
11 changes: 8 additions & 3 deletions src/ConversionsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ public function setEventByName(string $eventName): self

public function execute(): PromiseInterface
{
return (new EventRequestAsync(config('conversions-api.pixel_id')))
->setEvents([$this->event])
->execute();
$eventRequest = (new EventRequestAsync(config('conversions-api.pixel_id')))
->setEvents([$this->event]);

if ($testCode = config('conversions-api.test_code')) {
$eventRequest->setTestEventCode($testCode);
}

return $eventRequest->execute();
}

public function executePageViewEvent(): PromiseInterface
Expand Down

0 comments on commit db37aa4

Please sign in to comment.