Here is How To Add Google Trends Graphs in WordPress Post. You’ll Not Need Any Plugin or PHP Snippet. Page Loading Speed Will Not Be Hampered. All websites from Beginner WordPress to Expert WordPress, basically publishes an article with the name How To Add Google Trends Graphs in WordPress Post and Copy && Paste the same crap PHP Snippet which basically add a short code. PHP is not Python, PHP is a bad Language. Javascript is enough powerful. You do not need any “helping PHP” to add Google Trends Graphs in WordPress Post. For making PHP somewhat good, from HHVM to many things has been done, but actually it kept its history in the right track – Expires: Thu, 19 Nov 1981.
Before You Add Google Trends Graphs in WordPress Post
Definitely, you know what is Google Trends, else why you’ll read this article! If you do not know what is Google Trends, then perform a Google Web Search. Suppose you want to compare three search phrases – Internet of Things, IoT and Internet of Everything, you can get this URL for the same :
---
1 | http://www.google.com/trends/explore#q=Internet%20of%20Things%2C%20IoT%2C%20Internet%20of%20Everything&cmpt=q&tz= |
You’ll get a Javascript stuff if you click the < >
icon, below the graph (at the time of Publishing this article). What you want is this kind of thing (hover) :
Steps To Add Google Trends Graphs in WordPress Post
The Javascript will look like this :
1 | <script type=“text/javascript” src=“//www.google.com/trends/embed.js?hl=en-US&q=Internet+of+Things,+IoT,+Internet+of+Everything&cmpt=q&tz&tz&content=1&cid=TIMESERIES_GRAPH_AVERAGES_CHART&export=5&w=500&h=330”></script> |
Paste the whole thing on any good Text Editor. Separate the query part :
1 | ?hl=en–US&q=Internet+of+Things,+IoT,+Internet+of+Everything&cmpt=q&tz&tz&content=1&cid=TIMESERIES_GRAPH_AVERAGES_CHART&export=5&w=500&h=330 |
Use JsFiddle like Online Tool to check in real time. This thing we are providing you :
1 | <iframe scrolling=“no” style=“border:none;” width=“500” height=“530” src=“https://www.google.com/trends/fetchComponent” async defer></iframe> |
Within that part :
https://www.google.com/trends/fetchComponent
You will include that Javascript’s query part :
1 | <iframe scrolling=“no” style=“border:none;” width=“500” height=“330” src=“https://www.google.com/trends/fetchComponent?hl=en-US&q=Internet+of+Things,+IoT,+Internet+of+Everything&cmpt=q&tz&tz&content=1&cid=TIMESERIES_GRAPH_AVERAGES_CHART&export=5&w=500&h=330” async defer></iframe> |
If you have a normal sense, you’ll adjust the :
width="500" height="330"
I have created my own custom search terminologies :
Abhishek Ghosh – Dr. Abhishek Ghosh – thecustomizewindows.com The Customize Windows
Yes I can render the graph here :
and yes, for the website, the map too :
There is not much credit to discover this method. The Javascript HAS this line :
1 | src=“http://www.google.com/trends/fetchComponent?this” style=“border: none; |
Everyone knows that, Google loves iframe. I have added the async defer
to make it nonblocking Javascript. You can search our Website for many articles related to those async and defer. It is not illegal. Obviously you add on a Made for AdSense Website or Run Millions of requests per day, obviously Google will blacklist your domain. You can test on Page Speed insights, no blocking Javascript for these stuffs.