Facebook conversion code is like this (Please note it includes <script>
and <noscript>
parts)
<!-- Facebook Conversion Code -->
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
... // more code here
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=6030151253043&cd[value]=0.00&cd[currency]=USD&noscript=1" /></noscript>
Usually I can put this code in a webpage if I want to track conversion when this webpage is loaded. However, now I want to track a conversion after a link is clicked. And the link goes to other website that is not within my control. Therefore, after a link is clicked, I need to execute the above code first and then goes to where the link points to.
Since there is <noscript>
part, I cannot put this piece of code into a onclick
function in my webpage. Hence, I am thinking to replace the external link with a PHP page that will executes this code first and then redirect to the desired destination.
I am wondering if there is a better way to do this?