In a number of articles we intend on publishing on our website, Googel's platform.js
JavaScript code will be referenced over and over. Rather than include it in very article, we've included the code here for reference. For the sake of convenience, we've included a WordPress plugin... although using the code in your custom functions file is almost always a more prudent option.
While the code may be rendered anywhere on your page, Google recommends the footer as it may improve load time. The only exception is when using any of the JavaScript API methods; the API code needs to be placed in the page after the script
inclusion.
By itself this code doesn't perform any function. Its purpose is to support various Google related posts on our blog.
WordPress Function
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.
■ ■ ■
Alternatives
If you were to use the dynamic code (no longer used by us for most of our shortcodes), the following will add the JavaScript to the WP footer. It is required that it be rendered after the last widget tag (the footer will do this).
If adding language, or if you'reusing onload
callback to execute code after all dependencies have loaded, use the following.
More details are available on Google's developer website .
PHP Code
Used outside of WP, the function is virtually identical.
Note: All the Google functions have changed since we first published similar code on Internoetics. It's the first JavaScript block that's made available in the downloads below.
Download
This download is no longer available.