Learning to code is similar to learning to drive. It opens up a world of opportunities.

From a marketer’s point of view the ability to interpret, edit and write code is an incredibly useful skill to add to your toolkit.

What can you do with such abilities?

  • Understand / troubleshoot technical on-site issues from an SEO perspective
  • Create your own content
  • Complete small tasks which you normally sent across to developers 
  • Build your own tools, scripts and apps
  • Start your own business!

How can I learn?

There are many resources available to help you learn. I recommend the following more interactive resources:

  • Codecademy. Learn to code interactively for free. Good learning curve.
  • Treehouse. 1,000’s of videos with interactive challenges and member forum for a low monthly price.

Build your own simple keyword tool

You’ve heard of Ubersuggest right? It’s a popular keyword suggestion tool using data from Google suggest.

Did you know that Ubersuggest has an API (application programming interface) so you can use the same keyword data to create your own keyword tool?

Ubersuggest

Using PHP I’m going to help you create your own simple keyword tool. If you’re new to PHP I’d recommend taking the HTML (Hyper Text Markup Language) and PHP (Hypertext Preprocessor) lessons on Codecademy first.

Let’s get some admin out of the way.

  1. Sign up for a free Mashape account to access the API marketplace.
  2. Subscribe to Ubersuggest. This gives you 10 free queries per day and will charge you $0.05 per additional query.
  3. Click the ‘key’ symbol in the top navigation. Next to ‘Production Keys’ click ‘Create Key’. In the newly appearing box click the header to give it a more memorable name. Copy the long key for future use in your tool.

    Just below the API key you will see a search box which allows you to search for an API from which you have previously subscribed. Search for your ‘Ubersuggest’ and it should appear as an option. Click on this. This will link this API to your newly created key.

  4. Within the documentation for their API we will use the ‘suggest‘ endpoint. This returns a simple set of keyword suggestions for a given search term.

Now to the exciting bit!

Open a new file within your favourite web editor (Notepad++ is ideal). Look at the code snippet below (the text version of this can be found here – simply copy and paste the entire PHP code snippet into your new file). Save it as a PHP file (.php). We will break down the PHP code into four sections and go through each.

  1. Keyword Settings. To gather keyword suggestions we will need to provide the API with four options:
    1. Keyword. This is the keyword that you want to find related keywords for. In our example above I’ve added “new homes” as the keyword (please experiment by adding your own). This is then saved in the PHP variable $keyword.
    2. Language. You can add an ISO language code to tailor the keyword results to a specific language. In the example we have set the language PHP variable ($language) to “en” (English).
    3. Country. You can add an ISO country code to tailor the keyword results to a specific country. In the example we have set country PHP variable ($country) to “us” (United States).
    4. Source. The Ubersuggest API allows you to gather results from one of four Google channels. These are web, image, shopping and video. In the example we have set the source PHP variable ($source) to “web”.
  2. This is where you will add the Mashape API key you created earlier. This will save the API key to the PHP variable $api_key.
  3. This section looks at the API call which will send a request to Ubersuggest and return keyword results for your keyword tool.
    1. The API call requires access to Unirest PHP library. This can be downloaded here (click ‘Download ZIP’ on the right hand side).
    2. The value assigned to the $response variable constructs the API call based on your keyword settings in section 1. $response will hold the returned data from the API call.
  4. We have the results in a raw format. We now need to do something with this and present it on screen in a readable format.
    1. An IF statement checks if there if there are results stored in the $response variable. If this is false then the message “No Keywords Found” will be displayed on screen.
    2. If true, a FOREACH function will loop through all the individual keywords and display them on-screen in a bulleted list.

Don’t forget to save your file. Upload to a PHP supported web host once ready. Unzip the ‘lib’ folder from the Unirest PHP library you downloaded earlier (step 3a) and upload it to the same directory as your new PHP file. Running the file in your web browser will display something like the following:

Keyword Results

You’ve now got a list of relevant / trending keywords using Google suggest data.

That’s it! You’ve built your own keyword tool. Start experimenting with the code to learn and do your own thing with the data. Experiment with the many other APIs on Mashape at your own pace. Sentiment analysis? Face recognition? It’s all possible!