title: Facebook Pixel to track a click on a link
body: <p>I want to track each time someone clicks on a link on my web (this click makes a file to be downloaded) to optimise my Facebook Ads (pay per conversion). After including the Facebook pixel in the head section of my web, I have to track this event, for example as a "lead", so I'm using this piece of code at the beginning of the body:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $( '#link' ).click(function() {
  fbq('track', 'Lead');
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Please note that "link" is the id I've set for the link:</p>
  
  <pre><code>&lt;a id="link" href="/content/file.zip"&gt;press here&lt;/a&gt;
  </code></pre>
  
  <p>However, I'm tracking a "PageView" (because of the first code in the head section), but I'm not tracking the lead event (the click on the link).</p>
  
  <p>I've also tried this one:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("#link").on('click', function() {
  fbq('track', 'Lead');
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>And I've also tried with an onclick event in the link, like this:</p>
  
  <pre><code>&lt;a href="#link" onclick="return formDownloaded();"&gt;press here&lt;/a&gt;
  
  &lt;script type="text/javascript"&gt;
  function fileDownloaded() {
  fbq('track', 'Lead');
  return true;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Nothing works for me (I've also put the code of the event at the end of the body section). What am I doing wrong?</p>
  
  <p>Thanks a lot.</p>