0

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&amp;cd[value]=0.00&amp;cd[currency]=USD&amp;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?

Joe Huang
  • 6,296
  • 7
  • 48
  • 81
  • @ceejayoz Yes, I asked similar question in the question you consider duplicate. But that question has been mistakenly considered duplicate and closed for further answers. Besides, someone edited that question into some form that has totally changed my original perspective about the question. My current question should happen to many other people who use Facebook conversion code. And maybe someone can answer it from a different perspective, not just about executing noscript when a link is clicked. – Joe Huang Nov 11 '15 at 02:28
  • Rather than reposting the question, please flag the post for moderator attention. I've voted to reopen your original, which you're welcome to edit if you feel its meaning has been changed. – ceejayoz Nov 11 '15 at 02:30
  • I think these two questions can exist at the same time. I don't really feel they are exact duplicate after someone changed the other question. They are now asking different things from different perspective. – Joe Huang Nov 11 '15 at 03:09

1 Answers1

0

I don't think there's a better way because you see any links that FB creates such as the ads or articles that the page posted, also gets redirects to page within facebook before it gets redirected to the actual link.

I would suggest you use Google Analytics and use UTM codes. I've used this too.

UTM Codes

cweitat
  • 1,199
  • 1
  • 11
  • 28