Trying to figure out how to redirect to a new page after dropping a Facebook retargeting pixel.
We already have everything else setup but want to add this functionality (the same as https://meteor.link/)
We currently use window.location.replace('https://thelinkgoeshere.com');
but I think the Facebook is async so we can't just add the pixel code above it.
Thanks for any help you can provide!
If you look closely at the Facebook pixel code, you'll notice that somewhere in that code, the dynamic script
tag being inserted by the pixel has it's async
property set to true
like so:
t.async=!0;
!0
evaluates to true
.
To change this behavior, find where this property is being set in the pixel, and change it to false:
t.async=false;
Normally this would not be recommended as turning off async
will block further execution until the script is loaded and executed, but in your case that's exactly what you need.
Once you set async
to false, it is guaranteed that the FB pixel JS code will load and run before the next script that follows the pixel:
<script>
// FB pixel here with async false
</script>
<script>
window.location.replace('https://thelinkgoeshere.com');
<script>