• I need to add an “onload” event on a particular page so Google can dynamically insert a trackable phone number in my page. This is known as “google forwarding numbers”. I am not a developer, don’t do PHP. My problem is, when Google says “add this snippet within the body tag”, how do I do that? I have to execute the following on a single page:

    <body onload=”_googWcmGet(‘number’, ‘1-800-123-4567’)”>
    <span class=”number”>1-800-123-4567</span>
    </body>

    Any help would be much appreciated!!

Viewing 14 replies - 16 through 29 (of 29 total)
  • Thanks for posting that Burnspot. Using your method, one would have to have that code on every page. Anyone know how you would apply this code to body tag on specific pages?

    Give this a shot, replace “testimonials” with the name of your page:

    <body <?php body_class(); if (is_page(‘testimonials’)){ echo “onload=\”myfunction(‘phone’,’800-555-1234′)\” “; } ?> >

    And replace the ‘phone’ class and the number with yours.

    For multiple pages you can use is_page(‘testimonials’ || ‘about’)
    For all pages except one use !is_page(‘testimonials’)

    Hope that helps

    Oops, replace “myfunction” with “_googWcmGet” so it reads:

    <body <?php body_class(); if (is_page(‘testimonials’)){ echo “onload=\”_googWcmGet(‘phone’,’800-555-1234′)\” “; } ?> >

    That should work.

    Hi, here is a easy way to setup website call tracking on your genesis theme. It’s super easy. I implemented it for a client and he paid me a mere $40 even though i asked for $200 so i got frustrated and decided to share it with others:)
    https://ecommppc.com/2014/09/19/setup-adwords-website-call-tracking-on-your-genesis-theme/

    Cucubura, I looked at your method but doesn’t your method end up putting it on every page? I need to do the same but it’s only supposed to go on the Contact page…..

    Genesis has an area at the bottom of every web page where you can add scripts, actually it exactly says: Suitable for custom tracking, conversion or other page-specific script. Must include script tags. Why wouldn’t you just add to this section of just the one page you need it to be in??

    THANKS!!

    Yes, absolutely. You can implement it however you want. That’s the beauty of coding.

    I just the particular method because my client had a phone in the header so had to do with site wide option:)

    Ok wow thank you the the quick reply!

    So would I put the On Body portion in the exact same area using my method?

    Yes, try that and if its not working then you can trouble shoot. Also have Google tag assistant for Google chrome handy to test.

    Ok great thanks! I will try that today and post back!

    Ok I added the Google script in the WordPress dashboard > pages > contact page > at the very bottom where in Genesis you can add scripts as I mentioned above and this is wrong because it places it outside of the body tag….

    hmm. You have to really figure out. Just place the JS script on the header and then onload code with the help of window onload.

    Siva

    Umm what do you mean

    onload code with the help of window onload ??

    I was also only given one code and my Adwords guy said to put it right after the opening body tag…

    Thanks for your help!

    I think I can simplify a *part* of the problem.

    Assuming that you have solved the problem of “how to modify the body tag and add the onload function” then …

    Assuming that you have solved that part for *ALL* pages (for example by editing the header.php file and simply editing the opening body tag) …

    Then you only insert the CSS tagging on the numbers on pages or other places where you want the substitution to happen.

    For example, if you ONLY wanted the substitution to happen on your contact page, then on that contact page where the phone number normally occurs, you insert “<span class=”number”>1-800-123-4567</span>” instead of simply “1-800-123-4567”

    That css span is what causes the google function to rewrite your default number to the google call-tracking number. If you no gotto the css span, then no rewriting will occur, even though the opening body tag has loaded the google function.

    So we can control what pages are modified by editing the content of the pages where we desire the phone numbers to be re-written. But we can load the google function on every page, no problem.

    Thank you for that reply trakwebster.

    I ended up just kind of cheating on this a little because it was taking up too much time. In the end I just put it right at the bottom of my page…right in the text editor actually using the text version and it is working. It’s not the best way to do it but seems ok. My Google Adwords acct is able to ‘see’ it ??

Viewing 14 replies - 16 through 29 (of 29 total)
  • The topic ‘How to Add "body onload" to a single page’ is closed to new replies.