esign / laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API
MIT License
54 stars 12 forks source link

PageView script appearing twice. #14

Closed paul-adams-985 closed 1 month ago

paul-adams-985 commented 2 months ago

I have this mostly working, but I get two PageView events with different eventID's for every page

<script>
fbq('track', 'PageView', {}, {"eventID":"6e357f69-9865-41b0-86e0-ac113c2daff5"});
</script>

<script>
fbq('track', 'PageView', {}, {"eventID":"70a05d00-ee01-4242-adee-2dda9a3d1139"});
</script>

My layout is:

           ...
           <x-conversions-api-facebook-pixel-script />
    </head>

    <body>
        ...
        @foreach(ConversionsApi::getEvents()->filterFacebookPixelEvents() as $event)
            <x-conversions-api-facebook-pixel-tracking-event :event="$event" />
        @endforeach

        <x-conversions-api-facebook-pixel-page-view />

    </body>

Is this correct?

paul-adams-985 commented 1 month ago

Solved: <x-conversions-api-facebook-pixel-page-view /> clears events before it is run, but not after. This means the PageView it generates is not cleared. In SPA type applications, this event is picked up again making it appear twice.