Title: Add JavaScript to specific page head
Last modified: August 21, 2016

---

# Add JavaScript to specific page head

 *  Resolved [jackterrmov](https://wordpress.org/support/users/jackterrmov/)
 * (@jackterrmov)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/)
 * Hi,
 * I’m looking to add a conversion pixel to the checkout page of our WordPress site,
   which uses WooCommerce. Does anybody know how to specifically do this? I’ve added
   scripts to the header.php before for things like Pingdom, but never to a specific
   page and I’m struggling to see how to do this.
 * Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Andrew Mills](https://wordpress.org/support/users/andrewmills/)
 * (@andrewmills)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/#post-4000171)
 * I’ve never specifically done what you are asking with WooCommerce and conversion
   pixels . . . but if I am understanding what you are trying to do, it sounds like
   you want to attach JavaScript only if the page is a specific page, and then the
   JavaScript creates some kind of beacon GIF, right?
 * I’d suggest taking a look at this first: [How to Conditionally Load Scripts In WordPress](http://www.organizedthemes.com/loading-scripts-conditionally/).
 * Once you’ve got the hang of that, swap out the is_home() ||has_post_format() 
   part with the [is_page() function](http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page)
   instead.
 * You can specify a precise page by their id number or title, so that should get
   you pretty close to what you want.
 *  Thread Starter [jackterrmov](https://wordpress.org/support/users/jackterrmov/)
 * (@jackterrmov)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/#post-4000174)
 * Hi Andrew!
 * Thanks for your response.
 * End result of what I’m wanting is to monitor the conversions, i.e. successful
   checkouts that result from referrals from a third party site, who’ve provided
   the conversion pixel.
 * So, I guess switching out the is_home for is_page title is the way to go, right?
   And that would be within header.php in the editor of wordpress?
 *  [Andrew Mills](https://wordpress.org/support/users/andrewmills/)
 * (@andrewmills)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/#post-4000287)
 * You are quite welcome.
 * And yes, I’d swap out the is_home for is_page, using either the page_id or the
   title. I might lean towards id more than title though, so I could change the 
   title without breaking anything.
 * As for header.php . . . it depends. Most people like to put their JavaScripts
   in the footer (for speed, make sure the majority of the document has been rendered
   before the script acts, etc.)
 * But that’s the great & crazy thing about WordPress– there’s probably six different
   ways you could pull this off. 🙂
 *  Thread Starter [jackterrmov](https://wordpress.org/support/users/jackterrmov/)
 * (@jackterrmov)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/#post-4000300)
 * Haha! You’re exactly right, always more than one way to skin a cat!
 * Thanks so much, Andrew, this was super helpful!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Add JavaScript to specific page head’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [jackterrmov](https://wordpress.org/support/users/jackterrmov/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/add-javascript-to-specific-page-head/#post-4000300)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
