In my Laravel project, I'm successfully tracking frontend events using the JavaScript code fbq('track', 'PageView')
, which works well for tracking page views.
However, when attempting to use the MetaPixel::track()
method within a Laravel controller, I used the following code:
use Combindma\FacebookPixel\Facades\MetaPixel;
MetaPixel::track('SignIn', [
'User_Email' => $customer->email,
'Status' => 'logged in successfully'
]);
Despite installing all the necessary dependencies and adding the required code in the config file, the event tracking does not seem to function as expected.
<?php
return [
/*
* The Meta pixel id, should be a code that looks something like "1202417153106158".
*/
'pixel_id' => env('META_PIXEL_ID', ''),
/*
* The key under which data is saved to the session with flash.
*/
'session_key' => env('META_PIXEL_SESSION_KEY', config('app.name').'_metaPixel'),
/*
* Only if you plan using Conversions API for server events
* To use the Conversions API, you need an access token. For Documentation please see:
*/
'token' => env('META_PIXEL_TOKEN', ''),
/*
* Enable or disable advanced matching. Useful for adjusting user privacy.
*/
'advanced_matching_enabled' => env('META_PIXEL_ADVANCED_MATCHING_ENABLED', true),
/*
* Enable or disable script rendering. Useful for local development.
*/
'enabled' => env('META_PIXEL_ENABLED', true),
/*
* Enable or disable logging. Useful for debugging.
*/
'logging' => env('META_PIXEL_LOGGING', true),
/*
* This is used to test server events
*/
'test_event_code' => env('META_TEST_EVENT_CODE'),
];
Can anyone help me out, so that i can track my events in laravel