_:n4def9d9406d249b0926fdf7eec1d0655xb0
<http://schema.org/articleBody>
"<p>I&rsquo;m a self-funded start-up business owner. As such, I want to get as much as I can for free before convincing our finance director to spend our hard-earned bootstrapping funds. I&rsquo;m also an analyst with a background in data and computer science, so a bit of a geek by any definition.</p>\n<p>What I try to do, with my SEO analyst hat on, is hunt down great sources of free data and wrangle it into something insightful. Why? Because there&rsquo;s no value in basing client advice on conjecture. It&rsquo;s far better to combine quality data with good analysis and help our clients better understand what&rsquo;s important for them to focus on.<br /></p>\n<p>In this article, I will tell you how to get started using a few free resources and illustrate how to pull together unique analytics that provide useful insights for your blog articles if you&rsquo;re a writer, your agency if you&rsquo;re an SEO, or your website if you&rsquo;re a client or owner doing SEO yourself.</p>\n<p>The scenario I&rsquo;m going to use is that I want analyze some SEO attributes (e.g. backlinks, Page Authority etc.) and look at their effect on Google ranking. I want to answer questions like &ldquo;Do backlinks really matter in getting to Page 1 of SERPs?&rdquo; and &ldquo;What kind of Page Authority score do I really need to be in the top 10 results?&rdquo; To do this, I will need to combine data from a number of Google searches with data on each result that has the SEO attributes in that I want to measure.</p>\n<p>Let&rsquo;s get started and work through how to combine the following tasks to achieve this, which can all be setup for free:</p>\n<ul><li>Querying with Google Custom Search Engine</li>\n<li>Using the free Moz API account</li>\n<li>Harvesting data with PHP and MySQL</li>\n<li>Analyzing data with SQL and R</li>\n</ul><h2>Querying with Google Custom Search Engine</h2>\n<p>We first need to query Google and get some results stored. To stay on the right side of Google&rsquo;s terms of service, we&rsquo;ll not be scraping Google.com directly but will instead use <a href=\"https://support.google.com/customsearch/answer/4513751?hl=en\">Google&rsquo;s Custom Search</a> feature. Google&rsquo;s Custom Search is designed mainly to let website owners provide a Google like search widget on their website. However, there is also a <a href=\"https://developers.google.com/custom-search/v1/using_rest\">REST</a> based <a href=\"https://developers.google.com/custom-search/v1/overview\">Google Search API</a> that is free and lets you query Google and retrieve results in the popular <a href=\"https://developers.google.com/custom-search/v1/overview\">JSON format</a>. There are <a href=\"https://developers.google.com/webmaster-tools/search-console-api-original/limits\">quota limits</a> but these can be configured and extended to provide a good sample of data to work with.</p>\n<p>When <a href=\"https://www.phpclasses.org/blog/post/334-PHP-Tutorial-on-using-the-Official-Google-Search-API.html\">configured correctly</a> to search the entire web, you can send queries to your Custom Search Engine, in our case using PHP, and treat them like Google responses, albeit with some caveats. The main limitations of using a Custom Search Engine are: (i) it doesn&rsquo;t use some Google Web Search features such as personalized results and; (ii) it may have a subset of results from the Google index if you include more than ten sites.</p>\n<p>Notwithstanding these limitations, there are many <a href=\"https://developers.google.com/custom-search/v1/cse/list\">search options</a> that can be passed to the Custom Search Engine to proxy what you might expect Google.com to return. In our scenario, we passed the following when making a call:</p>\n<pre>\nhttps://www.googleapis.com/customsearch/v1?key=&lt;google_api_id&gt;&amp;userIp=\n&lt;ip_address&gt;&amp;cx&lt;custom_search_engine_id&gt;&amp;q=iPhone+X&amp;cr=countryUS&amp;start=\n1&lt;/custom_search_engine_id&gt;&lt;/ip_address&gt;&lt;/google_api_id&gt;\n</pre>\n<p>Where:</p>\n<ul><li><a href=\"https://www.googleapis.com/customsearch/v1\">https://www.googleapis.com/customsearch/v1</a> &ndash; is the URL for the Google Custom Search API</li>\n<li>key=&lt;GOOGLE_API_ID&gt; &ndash; Your <a href=\"https://developers.google.com/custom-search/v1/overview#api_key\">Google Developer API</a> Key</li>\n<li>userIp=&lt;IP_ADDRESS&gt; &ndash; The IP address of the local machine making the call</li>\n<li>cx=&lt;CUSTOM_SEARCH_ENGINE_ID&gt; &ndash; Your <a href=\"https://cse.google.com/cse/all\">Google Custom Search Engine</a> ID</li>\n<li>q=iPhone+X &ndash; The Google query string (&lsquo;+&rsquo; replaces &lsquo; &lsquo;)</li>\n<li>cr=countryUS &ndash; Country restriction (from Goolge&rsquo;s <a href=\"https://developers.google.com/custom-search/docs/xml_results_appendices#countryCollections\">Country Collection Name</a> list)</li>\n<li>start=1 &ndash; The index of the first result to return &ndash; e.g. SERP page 1. Successive calls would increment this to get pages 2&ndash;5.</li>\n</ul><p>Google has said that the <a href=\"https://support.google.com/customsearch/answer/70392?hl=en\">Google Custom Search engine differs from Google .com</a>, but in my limited prod testing comparing results between the two, I was encouraged by the similarities and so continued with the analysis. That said, keep in mind that the data and results below come from Google Custom Search (using &lsquo;whole web&rsquo; queries), not Google.com.</p>\n<h2>Using the free Moz API account</h2>\n<p>Moz provide an <a href=\"https://moz.com/products/api\">Application Programming Interface</a> (API). To use it you will need to register for a <a href=\"https://moz.com/products/api/keys\">Mozscape API key</a>, which is free but limited to 2,500 rows per month and one query every ten seconds. Current <a href=\"https://moz.com/products/api/pricing\">paid plans</a> give you increased quotas and start at $250/month. Having a free account and API key, you can then query the <a href=\"https://moz.com/help/links-api/getting-started/example-api-call\">Links API</a> and analyze the following <a href=\"https://moz.com/help/links-api/making-calls/url-metrics\">metrics</a>:</p>\n<table class=\"table-basic table-row-hover\"><thead><tr><th>\n<p>Moz data field</p>\n</th>\n<th>\n<p>Moz API code</p>\n</th>\n<th>\n<p>Description</p>\n</th>\n</tr></thead><tbody readability=\"13.386235955056\"><tr readability=\"2.6666666666667\"><td>\n<p>ueid</p>\n</td>\n<td>\n<p>32</p>\n</td>\n<td readability=\"4.3478260869565\">\n<p>The number of external <a href=\"https://moz.com/help/guides/moz-glossary#equity\">equity</a> links to the URL</p>\n</td>\n</tr><tr readability=\"6\"><td>\n<p>uid</p>\n</td>\n<td>\n<p>2048</p>\n</td>\n<td readability=\"7\">\n<p>The number of links (external, equity or nonequity or not,) to the URL</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>umrp**</p>\n</td>\n<td>\n<p>16384</p>\n</td>\n<td readability=\"6\">\n<p>The MozRank of the URL, as a normalized 10-point score</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>umrr**</p>\n</td>\n<td>\n<p>16384</p>\n</td>\n<td readability=\"6\">\n<p>The MozRank of the URL, as a raw score</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>fmrp**</p>\n</td>\n<td>\n<p>32768</p>\n</td>\n<td readability=\"6\">\n<p>The MozRank of the URL's subdomain, as a normalized 10-point score</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>fmrr**</p>\n</td>\n<td>\n<p>32768</p>\n</td>\n<td readability=\"6\">\n<p>The MozRank of the URL's subdomain, as a raw score</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>us</p>\n</td>\n<td>\n<p>536870912</p>\n</td>\n<td readability=\"6\">\n<p>The HTTP status code recorded for this URL, if available</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>upa</p>\n</td>\n<td>\n<p>34359738368</p>\n</td>\n<td readability=\"6\">\n<p>A normalized 100-point score representing the likelihood of a page to rank well in search engine results</p>\n</td>\n</tr><tr readability=\"4.5\"><td>\n<p>pda</p>\n</td>\n<td>\n<p>68719476736</p>\n</td>\n<td readability=\"6\">\n<p>A normalized 100-point score representing the likelihood of a domain to rank well in search engine results</p>\n</td>\n</tr></tbody></table><p>NOTE: Since this analysis was captured, Moz documented that they have deprecated these fields. However, in testing this (15-06-2019), the fields were still present.</p>\n<p>Moz API Codes are added together before calling the Links API with something that looks like the following:</p>\n<pre>\nwww.apple.com%2F?Cols=103616137253&amp;AccessID=MOZ_ACCESS_ID&amp;\nExpires=1560586149&amp;Signature=&lt;MOZ_SECRET_KEY&gt;\n</pre>\n<p>Where:</p>\n<ul><li>http://lsapi.seomoz.com/linkscape/url-metrics/\" class=\"redactor-autoparser-object\"&gt;http://lsapi.seomoz.com/linksc... &ndash; Is the URL for the Moz API</li>\n<li>http%3A%2F%2F<a href=\"http://www.apple.com%2F/\">www.apple.com%2F</a> &ndash; An encoded URL that we want to get data on</li>\n<li>Cols=103616137253 &ndash; The sum of the Moz API codes from the table above</li>\n<li>AccessID=MOZ_ACCESS_ID &ndash; An encoded version of the Moz Access ID (found in your API account)</li>\n<li>Expires=1560586149 &ndash; A timeout for the query - set a few minutes into the future</li>\n<li>Signature=&lt;MOZ_SECRET_KEY&gt; &ndash; An encoded version of the Moz Access ID (found in your API account)</li>\n</ul><p>Moz will return with something like the following JSON:</p>\n<pre>\nArray\n(\n    [ut] =&gt; Apple\n    [uu] =&gt; &lt;a href=\"http://www.apple.com/\" class=\"redactor-autoparser-object\"&gt;www.apple.com/&lt;/a&gt;\n    [ueid] =&gt; 13078035\n    [uid] =&gt; 14632963\n    [uu] =&gt; www.apple.com/\n    [ueid] =&gt; 13078035\n    [uid] =&gt; 14632963\n    [umrp] =&gt; 9\n    [umrr] =&gt; 0.8999999762\n    [fmrp] =&gt; 2.602215052\n    [fmrr] =&gt; 0.2602215111\n    [us] =&gt; 200\n    [upa] =&gt; 90\n    [pda] =&gt; 100\n)\n</pre>\n<p>For a great starting point on querying Moz with PHP, Perl, Python, Ruby and Javascript, see this <a href=\"https://github.com/seomoz/SEOmozAPISamples\">repository on Github</a>. I chose to use PHP.</p>\n<h2>Harvesting data with PHP and MySQL</h2>\n<p>Now we have a Google Custom Search Engine and our Moz API, we&rsquo;re almost ready to capture data. Google and Moz respond to requests via the JSON format and so can be queried by many popular programming languages. In addition to my chosen language, PHP, I wrote the results of both Google and Moz to a database and chose <a href=\"https://dev.mysql.com/downloads/mysql/\">MySQL Community Edition</a> for this. Other databases could be also used, e.g. Postgres, Oracle, Microsoft SQL Server etc. Doing so enables persistence of the data and ad-hoc analysis using SQL (Structured Query Language) as well as other languages (like R, which I will go over later). After creating database tables to hold the Google search results (with fields for rank, URL etc.) and a table to hold Moz data fields (ueid, upa, uda etc.), we&rsquo;re ready to design our data harvesting plan.</p>\n<p>Google provide a <a href=\"https://developers.google.com/webmaster-tools/search-console-api-original/v3/limits\">generous quota</a> with the Custom Search Engine (up to 100M queries per day with the same Google developer console key) but the Moz free API is limited to 2,500. Though for Moz, paid for options provide between 120k and 40M rows per month depending on plans and range in cost from $250&ndash;$10,000/month. Therefore, as I&rsquo;m just exploring the free option, I designed my code to harvest 125 Google queries over 2 pages of SERPs (10 results per page) allowing me to stay within the Moz 2,500 row quota. As for which searches to fire at Google, there are numerous resources to use from. I chose to use <a href=\"https://www.mondovo.com/keywords/\">Mondovo</a> as they provide numerous lists by category and up to 500 words per list which is ample for the experiment.</p>\n<p>I also rolled in a few PHP helper classes alongside my own code for database I/O and HTTP.</p>\n<p>In summary, the main PHP building blocks and sources used were:</p>\n<p>One factor to be aware of is the <a href=\"https://moz.com/products/api/pricing\">10 second interval between Moz API calls</a>. This is to prevent Moz being overloaded by free API users. To handle this in software, I wrote a \"query throttler\" which blocked access to the Moz API between successive calls within a timeframe. However, whilst working perfectly it meant that calling Moz 2,500 times in succession took just under 7 hours to complete.</p>\n<h2>Analyzing data with SQL and R</h2>\n<p>Data harvested. Now the fun begins!</p>\n<p>It&rsquo;s time to have a look at what we&rsquo;ve got. This is sometimes called <a href=\"https://en.wikipedia.org/wiki/Data_wrangling\">data wrangling</a>. I use a free statistical programming language called <a href=\"https://www.r-project.org/\">R</a> along with a development environment (editor) called <a href=\"https://www.rstudio.com/\">R Studio</a>. There are other languages such as <a href=\"https://www.stata.com/\">Stata</a> and more graphical data science tools like <a href=\"https://www.tableau.com/trial/tableau-software?utm_campaign_id=2017049&amp;utm_campaign=Prospecting-CORE-ALL-ALL-ALL-ALL&amp;utm_medium=Paid+Search&amp;utm_source=Google+Search&amp;utm_language=EN&amp;utm_country=MED&amp;kw=tableau&amp;adgroup=CTX-Brand-Core-E-control&amp;adused=324828617927&amp;matchtype=e&amp;placement=&amp;gclid=Cj0KCQjwrpLoBRD_ARIsAJd0BIXnBYieXX5FJwigqpHUeCzYyst1FnikQt5GqfIxkh0Fy8eNNpFuN5AaAhbxEALw_wcB&amp;gclsrc=aw.ds\">Tableau</a>, but these cost and the finance director at Purple Toolz isn&rsquo;t someone to cross!</p>\n<p>I have been using R for a number of years because it&rsquo;s open source and&nbsp;it has many third-party libraries, making it extremely versatile and appropriate for this kind of work.</p>\n<p>Let&rsquo;s roll up our sleeves.</p>\n<p>I now have a couple of database tables with the results of my 125 search term queries across 2 pages of SERPS (i.e. 20 ranked URLs per search term). Two database tables hold the Google results and another table holds the Moz data results. To access these, we&rsquo;ll need to do a database INNER JOIN which we can easily accomplish by using the <a href=\"https://cran.r-project.org/web/packages/RMySQL/index.html\">RMySQL</a> package with R. This is loaded by typing \"install.packages('RMySQL')\" into R&rsquo;s console and including the line \"library(RMySQL)\" at the top of our R script.</p>\n<p>We can then do the following to connect and get the data into an R data frame variable called \"theResults.\"</p>\n<pre>\nlibrary(RMySQL)\n# INNER JOIN the two tables\ntheQuery &lt;- \"\n    SELECT A.*, B.*, C.*\n    FROM\n    (\n        SELECT \n            cseq_search_id\n        FROM cse_query\n    ) A -- Custom Search Query\n    INNER JOIN\n    (\n        SELECT \n            cser_cseq_id,\n            cser_rank,\n            cser_url\n        FROM cse_results\n    ) B -- Custom Search Results\n    ON A.cseq_search_id = B.cser_cseq_id\n    INNER JOIN\n    (\n        SELECT *\n        FROM moz\n    ) C -- Moz Data Fields\n    ON B.cser_url = C.moz_url\n    ;\n\"\n# [1] Connect to the database\n# Replace USER_NAME with your database username\n# Replace PASSWORD with your database password\n# Replace MY_DB with your database name\ntheConn &lt;- dbConnect(dbDriver(\"MySQL\"), user = \"USER_NAME\", password = \"PASSWORD\", dbname = \"MY_DB\")\n# [2] Query the database and hold the results\ntheResults &lt;- dbGetQuery(theConn, theQuery)\n# [3] Disconnect from the database\ndbDisconnect(theConn)\n</pre>\n<p>NOTE: I have two tables to hold the Google Custom Search Engine data. One holds data on the Google query (cse_query) and one holds results (cse_results).</p>\n<p>We can now use R&rsquo;s full range of statistical functions to begin wrangling.</p>\n<p>Let&rsquo;s start with some summaries to get a feel for the data. The process I go through is basically the same for each of the fields, so let&rsquo;s illustrate and use Moz&rsquo;s &lsquo;UEID&rsquo; field (the number of external <a href=\"https://moz.com/help/guides/moz-glossary#equity\">equity</a> links to a URL). By typing the following into R I get the this:</p>\n<pre>\n&gt; summary(theResults$moz_ueid)\n   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. \n      0       1      20   14709     182 2755274 \n&gt; quantile(theResults$moz_ueid,  probs = c(1, 5, 10, 25, 50, 75, 80, 90, 95, 99, 100)/100)\n       1%        5%       10%       25%       50%       75%       80%       90%       95%       99%      100% \n      0.0       0.0       0.0       1.0      20.0     182.0     337.2    1715.2    7873.4  412283.4 2755274.0 \n</pre>\n<p>Looking at this, you can see that the data is skewed (a lot) by the relationship of the median to the mean, which is being pulled by values in the upper quartile range (values beyond 75% of the observations). We can however, plot this as a <a href=\"http://www.sthda.com/english/wiki/ggplot2-box-plot-quick-start-guide-r-software-and-data-visualization\">box and whisker plot in R</a> where each X value is the distribution of UEIDs by rank from Google Custom Search position 1-20.</p>\n<p>Note we are using a log scale on the y-axis so that we can display the full range of values as they vary a lot!</p>\n<img src=\"https://altreboot.com/wp-content/uploads/2019/10/5daf56c76bcc50.73801128.png\" width=\"1000\" height=\"400\" data-image=\"tp9084jtxqeo\" />A box and whisker plot in R of Moz&rsquo;s UEID by Google rank (note: log scale)\n<p>Box and whisker plots are great as they show a lot of information in them (see the geom_boxplot function in R). The purple boxed area represents the Inter-Quartile Range (IQR) which are the values between 25% and 75% of observations. The horizontal line in each &lsquo;box&rsquo; represents the median value (the one in the middle when ordered), whilst the lines extending from the box (called the &lsquo;whiskers&rsquo;) represent 1.5x IQR. Dots outside the whiskers are called &lsquo;outliers&rsquo; and show where the extents of each rank&rsquo;s set of observations are. Despite the log scale, we can see a noticeable pull-up from rank #10 to rank #1 in median values, indicating that the number of equity links might be a Google ranking factor. Let&rsquo;s explore this further with <a href=\"https://datavizcatalogue.com/methods/density_plot.html\">density plots</a>.</p>\n<p>Density plots are a lot like distributions (histograms) but show smooth lines rather than bars for the data. Much like a histogram, a density plot&rsquo;s peak shows where the data values are concentrated and can help when comparing two distributions. In the density plot below, I have split the data into two categories: (i) results that appeared on Page 1 of SERPs ranked 1-10 are in pink and; (ii) results that appeared on SERP Page 2 are in blue. I have also plotted the medians of both distributions to help illustrate the difference in results between Page 1 and Page 2.</p>\n<img src=\"https://altreboot.com/wp-content/uploads/2019/10/5daf56dc3862d5.12072192.png\" width=\"1000\" height=\"400\" data-image=\"ahpbhup4n0ng\" /><p>The inference from these two density plots is that Page 1 SERP results had more external equity backlinks (UEIDs) on than Page 2 results. You can also see the median values for these two categories below which clearly shows how the value for Page 1 (38) is far greater than Page 2 (11). So we now have some numbers to base our SEO strategy for backlinks on.</p>\n<pre>\n# Create a factor in R according to which SERP page a result (cser_rank) is on\n&gt; theResults$rankBin &lt;- paste(\"Page\", ceiling(theResults$cser_rank / 10))\n&gt; theResults$rankBin &lt;- factor(theResults$rankBin)\n# Now report the medians by SERP page by calling &lsquo;tapply&rsquo;\n&gt; tapply(theResults$moz_ueid, theResults$rankBin, median) \nPage 1 Page 2 \n    38     11 \n</pre>\n<p>From this, we can deduce that equity backlinks (UEID) matter and if I were advising a client based on this data, I would say they should be looking to get over 38 equity-based backlinks to help them get to Page 1 of SERPs. Of course, this is a limited sample and more research, a bigger sample and other ranking factors would need to be considered, but you get the idea.</p>\n<p>Now let&rsquo;s investigate another metric that has less of a range on it than UEID and look at Moz&rsquo;s UPA measure, which is the likelihood that a page will rank well in search engine results.</p>\n<pre>\n&gt; summary(theResults$moz_upa)\n   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. \n   1.00   33.00   41.00   41.22   50.00   81.00 \n&gt; quantile(theResults$moz_upa,  probs = c(1, 5, 10, 25, 50, 75, 80, 90, 95, 99, 100)/100)\n  1%   5%  10%  25%  50%  75%  80%  90%  95%  99% 100% \n  12   20   25   33   41   50   53   58   62   75   81 \n</pre>\n<p>UPA is a number given to a URL and ranges between 0&ndash;100. The data is better behaved than the previous UEID unbounded variable having its mean and median close together making for a more &lsquo;normal&rsquo; distribution as we can see below by plotting a histogram in R.</p>\n<img src=\"https://altreboot.com/wp-content/uploads/2019/10/5daf56dcd91e69.51216353.png\" width=\"1000\" height=\"400\" data-image=\"nssgzl0d8hym\" />A histogram of Moz&rsquo;s UPA score\n<p>We&rsquo;ll do the same Page 1 : Page 2 split and density plot that we did before and look at the UPA score distributions when we divide the UPA data into two groups.</p>\n<img src=\"https://altreboot.com/wp-content/uploads/2019/10/5daf56dd7e7630.66032277.png\" width=\"1000\" height=\"400\" data-image=\"ups95w5ga52s\" /><pre>\n# Report the medians by SERP page by calling &lsquo;tapply&rsquo;\n&gt; tapply(theResults$moz_upa, theResults$rankBin, median) \nPage 1 Page 2 \n    43     39 \n</pre>\n<p>In summary, two very different distributions from two Moz API variables. But both showed differences in their scores between SERP pages and provide you with tangible values (medians) to work with and ultimately advise clients on or apply to your own SEO.</p>\n<p>Of course, this is just a small sample and shouldn&rsquo;t be taken literally. But with free resources from both Google and Moz, you can now see how you can begin to develop analytical capabilities of your own to base your assumptions on rather than accepting the norm. SEO ranking factors change all the time and having your own analytical tools to conduct your own tests and experiments on will help give you credibility and perhaps even a unique insight on something hitherto unknown.</p>\n<p>Google provide you with a healthy free quota to obtain search results from. If you need more than the 2,500 rows/month Moz provide for free there are <a href=\"https://moz.com/products/api/pricing\">numerous paid-for plans</a> you can purchase. MySQL is a <a href=\"https://www.mysql.com/\">free download</a> and R is also a <a href=\"https://www.r-project.org/about.html\">free package</a> for statistical analysis (and much more).</p>\n<p>Go explore!</p>"
<https://altreboot.com/marketing/seo-analytics-for-free-combining-google-search-with-the-moz-api/>