Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (53 sloc) 2.99 KB
---
layout: page
title: Amazon Keyword Search Generator
permalink: /tools/amazon-keyword-search-generator/
jquery: true
share: true
---
<form onsubmit="generate();return false;">
<div><input id="input" type="text" name="search" />
<input onclick="generate()" value="Generate!" type="button"></div>
</form>
<ul id="output"></ul>
{% capture about %}
## Background - Why Write Another Keyword Tool For Amazon?
With all the Amazon Keyword Tools out there, why did I bother writing and publishing another one?
First and foremost - I like programming and creating things.
Secondly, though, this Amazon keyword generator does something that I haven't been able to find on any of the other keyword tools - a link to the Amazon search results page for that keyword.
What's so important about the search results? While keyword suggestions are nice (and an important part of this tool!) I wanted to see what the competition is for each of these keywords with one simple click. And what better place to see the competition than on Amazon itself!
I knew I could generate the appropriate URL after [analysing Amazon's search URLs]({{ site.url }}/amazon-url-anatomy-dissection/#amazon-search-urls).
I plan on using this mostly for my Merch By Amazon T-Shirt / Print-On-Demand business, but it can also be useful if you're an Amazon Associate (aka Amazon Affiliate), Amazon FBA seller, or just sell on Amazon in general.
## Technical Stuff
This is all written in the browser in JavaScript and uses JQuery. You can view the source either by simply [viewing source on your browser](view-source:{{ site.url }}/tools/amazon-keyword-search-generator/), or you can go to [the source hosted on GitHub](https://github.com/hendrixjoseph/hendrixjoseph.github.io/blob/master/tools/amazon-search-generator.html).
It uses a JSONP callback to Amazon's API, which I learned from [this post on Stackoverflow](https://stackoverflow.com/questions/31544085/using-amazons-affiliate-api-for-autocompletion).
{% endcapture %}
{{ about | markdownify }}
<script>
function generate() {
var alphabet = " abcdefghijklmnopqrstuvwxyz0123456789".split("");
var searchParts = ["<li><a href='https://www.amazon.com/s/?field-keywords=", "' >", "</a></li>"];
var amazon = "https://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q=";
var callback = "&callback=?";
var inputbox = $("#input");
var input = inputbox.val();
var outputbox = $("#output");
outputbox.empty();
alphabet.forEach(function(letter) {
var searchText = input + " " + letter;
var encodedSearchText = encodeURIComponent(searchText);
var list = $("<li />").append(searchText);
var sublist = $("<ul />");
list.append(sublist);
outputbox.append(list);
$.getJSON(amazon + encodedSearchText + callback,
function(result){
result[1].forEach(function(item) {
var encodedItem = encodeURIComponent(item);
sublist.append(searchParts[0] + encodedItem + searchParts[1] + item + searchParts[2]);
});
}
);
});
}
</script>
You can’t perform that action at this time.