Thursday, June 30, 2016

Leverage the power of IBM Watson in your AdWords campaigns

watson-1920In 2011, IBM Watson competed on Jeopardy! against the two reigning champions and easily took the first place prize of $1 million.

While that was some amazing marketing, the real prize was the technology developed as part of that effort. I suspect IBM has slowly been working that technology into its products, but it is also available directly as an API. If you’ve read any of my other posts, you know where this is going. Today, I’m sharing the script library I put together to leverage IBM Watson’s technology in my AdWords account.

One of the APIs available in the Watson Developer Cloud is called Alchemy Language, and it provides a set of endpoints to help you pull information and parse text from URLs. It can do things like automatically pulling dates, authors, concepts and keywords from a webpage with just a simple call. That last one sounds like it would be a great tool to add to our keyword research toolbox.

The example they give in the documentation is based on analyzing a Twitter feed for relevant keywords, but we can send in any URL we want. If you’re an agency, maybe you could leverage this API to make sure your customer’s keywords are relevant to the landing page they’re linking to. If you’re running your company’s campaigns, maybe you could analyze a competitor’s content to find keywords you might want to compete on as well.

One thing to note is that this is tool does not try to replace Google, so the keywords and topics Watson says are important will be slightly different than what Google says. At some level, both companies are trying to analyze text for topics and keywords, but there’s no doubt they are doing it very differently.

The Alchemy Language API is incredibly easy to use, but you will need to sign up for a developer token to call it. IBM has a free tier, which is plenty for what we are doing here, but of course, you can always pay for additional quota if you need to. At the end of the sign-up process, you will get something that looks like this:

{
"credentials": {
"url": "https://gateway-a.watsonplatform.net/calls",
"note": "It may take up to 5 minutes for this key to become active",
"apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}

Those credentials are what you pass to the library to make the calls. Here’s the library you can paste into the bottom of your AdWords Scripts for accessing this API. I’ll provide an example for using it at the end of the post.

/*************************************
* IBM Watson Alchemy Languge API v1.0
* By: Russ Savage (@russellsavage)
* Usage:
* var watson = new AlchemyLanguageAPI({
* "url": "https://gateway-a.watsonplatform.net/calls",
* "apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
* });
* // Example usage:
* var resp = watson.URLGetRankedKeywords({
* url : 'http://searchengineland.com/send-adwords-alerts-directly-slack-adwords-script-library-243870'
* });
*
* Full documentation on parameters can be found here:
* http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/alchemy-language/api/v1/
***********************************/
function AlchemyLanguageAPI(config) {
this.api_key = config.apikey;
this.base_url = config.url;
// This is a generic function to pull data from an endpoint
// and send it back as a json object.
this.callService = function(endpoint, conf) {
conf.apikey = this.api_key;
conf.outputMode = 'json';
var params = {
method : "POST",
payload : _buildQueryString(conf),
muteHttpExceptions : true
};
var resp = UrlFetchApp.fetch(this.base_url+endpoint, params);
var jsonResp = JSON.parse(resp.getContentText());
if(jsonResp.status == "OK") {
return JSON.parse(resp.getContentText());
} else {
throw jsonResp.status + " : " + jsonResp.statusInfo;
}
};
// This function is used to dynamically generate the individual endpoints of each endpoint.
this.generateFunctions = function() {
var endpoints = _getEndpoints();
for(var i in endpoints) {
var endpoint = endpoints[i];
this[endpoint] = new Function('params', "return this.callService('/url/"+endpoint+"', params);");
}
};
// This is a list of endpoints from the docs used for dynamically generating our functions
// http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/alchemy-language/api/v1/
function _getEndpoints() {
return ['URLGetCombinedData','URLGetAuthors','URLGetRankedConcepts',
'URLExtractDates','URLGetEmotion','URLGetRankedNamedEntities',
'URLGetFeedLinks','URLGetRankedKeywords','URLGetLanguage',
'URLGetMicroformatData','URLGetPubDate','URLGetRelations',
'URLGetTypedRelations','URLGetTextSentiment','URLGetTargetedSentiment',
'URLGetRankedTaxonomy','URLGetText','URLGetRawText','URLGetTitle'];
};
// This is our helper method to build the query string from
// the config object.
function _buildQueryString(keyValueMap) {
var query_string = [];
if(keyValueMap) {
Object.keys(keyValueMap).forEach(function(key) {
query_string.push(key+'='+encodeURIComponent(keyValueMap[key]));
});
}
return query_string.join('&');
}
this.generateFunctions();
}

It’s only a few lines because I am dynamically generating the functions for each endpoint. That means that anytime you see something like “POST /url/URLGetTypedRelations” in the docs, you can call it from your script code like “watson.URLGetTypedRelations(config)” and it will return the response already formatted as an object.

Here’s an example of parsing one of my old blog posts and finding the list of keywords that are related.

function main() {
// You can obtain the credentials by following the steps here:
// http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/alchemy-language/api/v1/#authentication
var watson = new AlchemyLanguageAPI({
"url": "https://gateway-a.watsonplatform.net/calls",
"apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
});
var resp = watson.URLGetRankedKeywords({
url : 'http://searchengineland.com/send-adwords-alerts-directly-slack-adwords-script-library-243870'
});
// Sort the results by relevance
resp.keywords.sort(function(a,b) {
return b.relevance - a.relevance;
});
// Just print them out
for(var i in resp.keywords) {
var keyword = resp.keywords[i];
Logger.log("Keyword: '" + keyword.text + "' Relevance : " + keyword.relevance);
}
}
view raw example_call.js hosted with ❤ by GitHub

Running that code in your account won’t make any changes, but should print out something like this below to help you get familiar with the library.

Keyword: 'Slack' Relevance : 0.937074
Keyword: 'adwords scripts' Relevance : 0.749439
Keyword: 'Slack API documentation' Relevance : 0.73206
Keyword: 'Slack channel' Relevance : 0.721681
Keyword: 'Slack notifications' Relevance : 0.67354
Keyword: 'longtime AdWords script' Relevance : 0.646626
Keyword: 'Slack alerts' Relevance : 0.594162
Keyword: 'Slack admin' Relevance : 0.590123
Keyword: 'Slack installation' Relevance : 0.574743
Keyword: 'AdWords Scripts Team' Relevance : 0.571386
Keyword: 'advocate Frederick Vallaeys' Relevance : 0.521221
Keyword: 'incoming webhooks integration' Relevance : 0.518891
Keyword: 'incredibly simple library' Relevance : 0.49775
Keyword: 'Search Engine Land' Relevance : 0.484813
Keyword: 'AdWords login' Relevance : 0.416478
Keyword: 'communication tool' Relevance : 0.357035
Keyword: 'best parts' Relevance : 0.340199
Keyword: 'huge number' Relevance : 0.337329
Keyword: 'Happy Slacking' Relevance : 0.331707
Keyword: 'useful features' Relevance : 0.329776
Keyword: 'new instance' Relevance : 0.328692
Keyword: 'SlackAPI library' Relevance : 0.323181
Keyword: 'Staff authors' Relevance : 0.31644
Keyword: 'simple messages' Relevance : 0.314975
Keyword: 'supporting reports' Relevance : 0.31262
Keyword: 'guest author' Relevance : 0.310867
Keyword: 'MailApp.sendEmail function' Relevance : 0.305653
Keyword: 'final note' Relevance : 0.29987
Keyword: 'account' Relevance : 0.218246
Keyword: 'inbox' Relevance : 0.210755
Keyword: 'emails' Relevance : 0.205071

And that’s all there is to it. Now you should be able to combine this with some of the other AdWords Scripts out there to find keywords related to your own landing pages or someone else’s. There are a few other endpoints on that list that might also be interesting, such as URLGetRankedConcepts or URLGetEmotion, but I haven’t played around with them too much.

The post Leverage the power of IBM Watson in your AdWords campaigns appeared first on Search Engine Land.



from SEO Rank Video Blog http://ift.tt/295eAn8
via IFTTT

No comments:

Post a Comment