• Resolved jackterrmov

    (@jackterrmov)


    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)
  • 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.

    Once you’ve got the hang of that, swap out the is_home() ||has_post_format() part with the is_page() function 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

    (@jackterrmov)

    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?

    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

    (@jackterrmov)

    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.