• Hi,
    I’m trying to add a google forwarding number to a wordpress website. This requires adding a code snippet directly in the <body> tag, like this:

    <body onload="_googWcmGet('number', '1-800-123-4567')">
    <span class="number">1-800-123-4567</span>
    </body>

    I can’t figure out a way to do this… The only way I know how to do this would be to add the code directly to the template (make a child theme), but i’d like to avoid that.

    Any help appreciated.
    Thx

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can add that using jQuery

    $('body').attr('onload', "_googWcmGet(\'number\', \'1-800-123-4567\')");

    Thread Starter Louno

    (@louno)

    Thanks for the answer, however, i’m not sure how to proceed, where do I paste that code?

    Thread Starter Louno

    (@louno)

    anyone??

    May i know your theme name and your site URL

    Thread Starter Louno

    (@louno)

    I’m using DIVI theme. URL isnt public currently.

    I tried using this script but it didn’t work:

    <script>
    window.onload=_googWcmGet(‘number’, ‘1-800-123-4567’);
    </script>

    I contacted the theme (divi) support team and they told me I have to modify the template file header.php … But like I said, i’d like to avoid making changes to theme files.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to add onload code INSIDE tag’ is closed to new replies.