Answers.Body: <p>You could override the Thank-you smarty template. Copy the one from templates/CRM/Contribute/Form/Contribution/ThankYou.tpl. Then you could do something like this:</p>
  
  <pre><code>{if $contributionPageID == 20}
  
      &lt;script type="text/javascript"&gt;
      {literal}
  
        function doFacebookStuff(){
        };
  
      {/literal}
      &lt;/script&gt;
  {/if}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T15:58:52.710Z
Answers.Text: Thanks Nicholai!  I upvoted this because it got me on the right track.  I wanted to add that a better approach would be a .extra.tpl file (more maintainable on upgrade) or an extension (easier to share).  I did the latter, see my answer.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T16:19:31.890Z
Answers.LastActivityDate: 2015-04-07T16:19:31.890Z
Answers.UserDisplayName: Nicholai
Answers.Body: <p>In Drupal, if you <a href="https://civicrm.stackexchange.com/questions/87/changing-the-default-urls-to-contribution-or-event-registration-pages">use an alias for the page</a>, you could check for that alias in a preprocess_html hook and insert some FB Conversion Pixel javascript if it's the right alias.</p>
  
  <p>Example:</p>
  
  <pre><code>function MYTHEME_preprocess_html(&amp;$vars) {
    $path = drupal_get_path_alias();
      if ($path == 'special-fb-contribpage-alias') {
      drupal_add_js(drupal_get_path('theme', 'MYTHEME') . '/js/facebook-conversion-pixel.js', 'file');
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-06T18:49:36.327Z
Answers.Text: I'd be interested to know what your solution was/is, Jon G, thanks
Answers.UserDisplayName: Lesley Evensen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-06T18:58:58.237Z
Answers.Text: @LesleyEvensen, the solution is here: http://civicrm.stackexchange.com/a/705/26
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T15:23:30.673Z
Answers.Text: Thanks for the tip - but I need to add this to the confirmation page, not the contribution page.  I don't think there's a way to use an alias for the confirmation page?
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T15:27:30.523Z
Answers.Text: Ah, got it. It wouldn't be ideal, but can you wedge it into the 'thank you' header or footer for that particular page?
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T15:33:29.190Z
Answers.Text: I think that Facebook gives you Javascript to insert - I don't think I can put JS into the header/footer.  I hope not!  But this gives me some good ideas, thank you.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T16:21:19.137Z
Answers.Text: I think they also give a <noscript> option (an image), but as I said, not ideal. Curious to see what you come up with. :)
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-07T15:20:22.863Z
Answers.LastActivityDate: 2015-04-07T15:20:22.863Z
Answers.UserDisplayName: Laryn
Answers.Body: <p>I ended up taking Nicholai's idea, but instead implemented it as an extension for better maintainability across upgrades - and for sharing.  Folks can see the extension here: <a href="https://github.com/PalanteJon/civicrm-facebook-conversion-pixel" rel="nofollow">https://github.com/PalanteJon/civicrm-facebook-conversion-pixel</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-31T20:34:08.567Z
Answers.Text: Thanks for creating this. How do I make sure it only applies to specific contribution pages?
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-31T20:48:40.657Z
Answers.Text: @Christia You'd have to customize the extension, or have someone else do it for you.  I wrote this up very quickly for a client and shared it - I never intended to make it more generally usable.  I can give a quote to make this more functional if you like!  Find me on chat.civicrm.org: Username is junglebird.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T16:42:42.037Z
Answers.Text: You may get more value from an extra tpl file, which would let you use the $amount variable to get actual conversion amount (vs. always reporting back to FB as $0).
Answers.UserDisplayName: Nicholai
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-08T13:41:25.093Z
Answers.Text: Thank you for creating the extension Jon G - in your .php code you may want to check for example if 'ga.js' exists and in that case, you need to insert the pixel image only, not the FB javascript function.  If Google Analytics or DoubleClick are installed on a site the FB code isn't 'smart' enough to deal with that, you need to just use the pixel
Answers.UserDisplayName: Lesley Evensen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-21T15:59:38.187Z
Answers.LastActivityDate: 2015-04-21T15:59:38.187Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>To track the efficacy of a Facebook ad campaign, my users want to insert a <a href="https://www.facebook.com/business/a/online-sales/conversion-tracking" rel="nofollow">Conversion Pixel</a> to some (but NOT all) contribution confirmation pages.  What's an effective way to do this?</p>
  
Tags: <civicontribute><facebook>
Title: Adding a Facebook Conversion Pixel Code to the contribution confirmation screen
ThreadText: # Adding a Facebook Conversion Pixel Code to the contribution confirmation screen
  
  (Asked by: username_0 on 2015-04-07)
  
  To track the efficacy of a Facebook ad campaign, my users want to insert a [Conversion Pixel](https://www.facebook.com/business/a/online-sales/conversion-tracking) to some (but NOT all) contribution confirmation pages. What's an effective way to do this?
  
  **Tags:** civicontribute, facebook
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-04-21. Score: 3 | Accepted answer
  
  I ended up taking username_1's idea, but instead implemented it as an extension for better maintainability across upgrades - and for sharing. Folks can see the extension here: <https://github.com/PalanteJon/civicrm-facebook-conversion-pixel>
  
  > **Comments:**
  > **username_1**: You may get more value from an extra tpl file, which would let you use the $amount variable to get actual conversion amount (vs. always reporting back to FB as $0).  
  > **username_3**: Thank you for creating the extension Jon G - in your .php code you may want to check for example if 'ga.js' exists and in that case, you need to insert the pixel image only, not the FB javascript function.  If Google Analytics or DoubleClick are installed on a site the FB code isn't 'smart' enough to deal with that, you need to just use the pixel  
  > **username_4**: Thanks for creating this. How do I make sure it only applies to specific contribution pages?  
  > **username_0**: @username_4 You'd have to customize the extension, or have someone else do it for you.  I wrote this up very quickly for a client and shared it - I never intended to make it more generally usable.  I can give a quote to make this more functional if you like!  Find me on chat.civicrm.org: Username is junglebird.  
  
  ---
  
  ### Answer by username_1 on 2015-04-07. Score: 3
  
  You could override the Thank-you smarty template. Copy the one from templates/CRM/Contribute/Form/Contribution/ThankYou.tpl. Then you could do something like this:
  {if $contributionPageID == 20}
  
      
  {/if}
  
  > **Comments:**
  > **username_0**: Thanks username_1!  I upvoted this because it got me on the right track.  I wanted to add that a better approach would be a .extra.tpl file (more maintainable on upgrade) or an extension (easier to share).  I did the latter, see my answer.  
  
  ---
  
  ### Answer by username_2 on 2015-04-07. Score: 1
  
  In Drupal, if you use an alias for the page, you could check for that alias in a preprocess_html hook and insert some FB Conversion Pixel javascript if it's the right alias.
  Example:
  function MYTHEME_preprocess_html(&$vars) {
    $path = drupal_get_path_alias();
      if ($path == 'special-fb-contribpage-alias') {
      drupal_add_js(drupal_get_path('theme', 'MYTHEME') . '/js/facebook-conversion-pixel.js', 'file');
    }
  }
  
  > **Comments:**
  > **username_0**: Thanks for the tip - but I need to add this to the confirmation page, not the contribution page.  I don't think there's a way to use an alias for the confirmation page?  
  > **username_2**: Ah, got it. It wouldn't be ideal, but can you wedge it into the 'thank you' header or footer for that particular page?  
  > **username_0**: I think that Facebook gives you Javascript to insert - I don't think I can put JS into the header/footer.  I hope not!  But this gives me some good ideas, thank you.  
  > **username_2**: I think they also give a <noscript> option (an image), but as I said, not ideal. Curious to see what you come up with. :)  
  > **username_3**: I'd be interested to know what your solution was/is, Jon G, thanks  
  > **username_2**: @LesleyEvensen, the solution is here: http://civicrm.stackexchange.com/a/705/26  
  
  ---
  
  