Using import.io API in AdWords

Posted on March 13, 2015 in

import.io is a great tool for extracting structured data from HTML. In this post, we’ll explore the possibilities of taking this data and auto updating our Ads in AdWords. Look at the following add for a Monster Moto mini bike showing the name, an image, product reviews, description, product color types, etc.

google-shopping-sample

Now you could create and maintain a spreadsheet manually to keep all your product information up to date. Or maybe you directly interact with the store’s database via API like our AdWords script with WooCommerce API example. But if you want to try and solve this problem without involving updates from your development team, import.io is an excellent solution.

Simple Example

 

function main() {
  importIO();
}

function importIO() {
  var GUID = 'YOUR GUID';
  var API_KEY = 'YOUR API KEY';
  var CONNECTOR = 'SOME CONNECTOR';
  var url = "https://query.import.io/store/connector/" + CONNECTOR + "/_query?_user=" + GUID + "&_apikey=" + API_KEY + "&input/webpage/url=http%3A%2F%2Fcdn.import.io%2Ftest%2Fpages%2Fbasic%2Findex.html";
  var response = UrlFetchApp.fetch(url);
  response = response.getContentText();
  var data = JSON.parse(response);
  Logger.log(response);
  for(var i=0; i < data.results.length; i++) {
    Logger.log(data.results[i]);
  }
}

The above example for AdWords scripts just uses one of the example URLs in the import.io API. You can see where I print the entire response, then loop through the results and log the data. Here’s a snippet of the output:

{
    "offset": 0,
    "results": [{
        "photo/_title": "Iron Man",
        "origin": "Earth",
        "more_info/_title": "Wikipedia",
        "photo": "http://cdn.import.io/integrate/img/iron-man.png",
        "more_info": "http://en.wikipedia.org/wiki/Iron_Man",
        "alter_egos": "Anthony Edward \"Tony\" Stark",
        "more_info/_text": "Iron Man on Wikipedia",
        "photo/_source": "img/iron-man.png",
        "skills": "Intellect Cyperpathic Link Strenght and durability Energy repulsors Missiles",
        "species": "Human",
        "photo/_alt": "Iron Man using repulsors",
        "name": "Iron Man"
    }, {
        "photo/_title": "Captain America",
        "origin": "Earth",
        "more_info/_title": "Wikipedia",
        "photo": "http://cdn.import.io/integrate/img/captain-america.png",
        "more_info": "http://en.wikipedia.org/wiki/Captain_America",
        "alter_egos": "Steven \"Steve\" Rogers",
        "more_info/_text": "Captain America on Wikipedia",
        "photo/_source": "img/captain-america.png",
        "skills": "Intellect Sheild-fighting Hyperkinetic senses Field commanding",
        "species": "Human",
        "photo/_alt": "Captain America looking forlorn",
        "name": "Captain America"
    },{
    ...
    ...
    ...

While this isn’t specific product data, you can follow the same procedure of your pages to extract the data from within your AdWords script. I hope this helps even a little bit pulling data into your account for more effective ads, but if you have any specific questions, feel free to ask in the comments below.

By Nathan Byloff

Nathan is the CTO for RankHammer. His area of expertise is technical SEO and everything to do with data - collection, analysis, etc. He is driven by automating any reporting task that has to be done more than once.