javascriptphplaravellaravel-duskfacebook-pixel

How to verify/assert that Facebook Pixel track events are actually working using laravel dusk?


I want to verify that facebook pixel 'track' event is actually firing when user perform signup ,

is there a way ? using Laravel dusk.

<<User successfully register's and then , pixel code is executed on the front side in the js.>>


Solution

  • I've successfully managed to do it ,

    ->assertScript('window.fbq.queue.length === 0'); //assumes that no fb events are pending
    

    When user successfully register, a pixel event is fired.

    fbq('track', 'Lead', {}, {eventID})
    

    My task was to write a test case in laravel dusk for this event that, it is actually dispatches or not when user registers.

    You can also check that fbq is actually exists or not

    $fbqExists = $browser->script('return typeof window.fbq !== "undefined"');