whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
312 stars 37 forks source link

How to add Facebook Pixel #25

Closed alien-rat closed 8 months ago

alien-rat commented 9 months ago

Hellow, how do i add facebook pixel?

lp Miha

toonvandenbos commented 8 months ago

Hi @alien-rat, you could add a custom cookie and attach the Facebook Pixel script to the consent response using the accepted closure. More information here: https://github.com/whitecube/laravel-cookie-consent/tree/main?tab=readme-ov-file#acceptedclosure-callback

Since Facebook's Pixel is a popular addition, I'd be happy to accept a PR that would make its configuration within this package easier. Please let me know how you ended up implementing it! :)

alien-rat commented 4 months ago

sorry but i tried evertyhing, but its not working at all.. $category = Cookies::category(key: 'accepted'); Cookies::accepted() // Targetting a category ->cookie(function(Cookie $cookie) { $cookie->accepted(function(Consent $consent) { $consent->cookie(value: 'off')->script(''); }); }); error: App\Providers\CookiesServiceProvider::App\Providers{closure}(): Argument #1 ($cookie) must be of type App\Providers\Cookie, Whitecube\LaravelCookieConsent\Cookie given, called in