Learn to code: programming hacks for marketers

Programmers aren’t the only people who should be coding at work. There are quite a few opportunities for you to incorporate coding into your workflow to speed things up. With these tricks not only will you be able to start learning how to code at your current job, you’ll also cut down the time you spend on repetitive tasks — making you (and your boss) much happier. In the long run, you will become more productive and will also learn skills that you can apply to future coding projects.

Difficulty level: Easy

1. Run social media accounts? Learn about URL parameters.

Learn how to add parameters to twitter URLs to pre-populate tweets that encourage your users to share your content. Facebook has a similar option. See this example.

2. Run A/B tests? Learn a bit of JavaScript.

A/B tests are usually run by including a small snippet of JavaScript code that shows or hides certain elements or changes a button color on a page. Implementing this will vary based on the service your company uses, but you can definitely write the JavaScript that makes these changes.

Example to change a button color for an A/B test

$('.homepage-header-button').css('background-color', 'aliceblue');

Note: This example assumes that your website is loading jQuery

3. Pull analytics reports with Google Analytics? Learn regex.

You can learn a bit of regex and make your filters in GA more specific. This can help save you time and allow you to look at site traffic more efficiently. In the example below we are filtering for traffic that is either organic or from a referrer using the regex referral|organic.

Difficulty level: Medium

4. Are you in charge of any email campaigns? Learn html/css or Liquid for email templating.

Want to improve your company’s emails Click-Through Rate? Although email templates are notably frustrating, you can learn some basic HTML and CSS skills to make emails better. Depending on how you are sending emails, you may also be able to use the templating language Liquid. Liquid allows for logic such as:

{% if customer_name %} Hello {{ customer_name }}, {% else %} Hey there! {% endif %}

Using this will not only make your emails better but it will help you learn some basic programming skills.

NOTE: I do definitely recommend testing your emails with something like Litmus though to make sure it works for all platforms.

5. Manually scraping data? Learn some Python

Sometimes you just need to pull all the image alt texts from a webpage. Beautiful soup is a python package that makes this process less painful! Don’t forget to check if python is installed first on your comp by running python -V in your terminal.

6. Use Google Sheets? Learn Google Script.

Go beyond conditional formatting and write Google Script. Google Script is a lot like JavaScript and allows you to write functions that you can then use in your spreadsheets. This is super helpful if you need a custom function to calculate a value or what to use an API (see #8 more details).

To write your script, open up a Google sheet and go to the Tools tab and select Script editor. After writing your function, you can go ahead and call it in the Google sheet. For example to run the function below you would type =pagespeed(“www.mywebsite.com”, “mobile”) into a cell.

The example below fetches the google page speed score for a website.

function pagespeed(url, strategy) {  
  var params = {
    'url': url,
    'strategy': strategy
  }

  var callDetails = {
    'payload' : params
  }

  apiUrl = "https://www.googleapis.com/"
  + "pagespeedonline/v2/runPagespeed?url=" 
  + url + "&strategy=" + strategy;

  response = UrlFetchApp.fetch(apiUrl);

  var dataAll = JSON.parse(response.getContentText());

  return dataAll["ruleGroups"]["SPEED"]["score"]

}

Note: Google Sheets/Google Script have almost no bounds. You can automate report creation and even email reminders if you spend enough time learning.

Difficulty level: Hard

7. Need to do a lot repetitive typing or data entry tasks? Learn some vim.

If you ever catch yourself copy/pasting 100 times, take a minute to step back. With a little vim knowledge, you can record keystrokes and very quickly run repeating tasks. Although it has a pretty high learning curve, the usefulness and productivity you will gain afterward are unparalleled. I’d recommend trying vim adventures to get started.

8. Need to ask engineers for data reports? Learn some SQL and use Dataclips

If you frequently need to look at company data for any sort of analysis, check out Heroku's Dataclips. You can create URLs that will run a specific SQL query on a database, and there are plenty of good resources out there to learn SQL.

9. Need to do almost anything else? Learn more about APIs

As I showed you in #6, you can use APIs to access data from other organizations / companies / developers to use in your own projects. Need the weather in your city? Need to convert money based on the current exchange rate? There are APIs for all these things and more. Here is an excellent list of publicly available APIs.

Have an interesting way you use code for your job? I’d love to hear about them and update my list. Shoot me an email at tatiana@thinkful.com or tweet @tatianatylosky. Also, if you want to start programming professionally, check out Thinkful’s Web Development Bootcamp — you work 1-on-1 with a mentor to learn new skills, solve problems, and build production apps.