## Algorithm Design for Minimization of Time Complexity

This project requires a bit of background, for those who aren’t familiar with Google Ads. (For those who are, please skip down to the horizontal bar.)

When you search for something, some ads may show up at the top of the results page. Those ads were paid for by companies who had decided those ads were bringing in enough profit to be worth it.

This particular project involves automation of a specific portion of step 2. To try to maximize their ads’ conversion rates, marketers only want to serve their ads to people who have the highest chance of clicking, and ultimately, converting. A very important tool in the marketer’s arsenal for this goal is the negative.

Negatives, short for negative keywords, are keywords that tell the search engine that they should not display your ad if that keyword is part of the search query. For a quick example of why you might want to do this, consider that you’re running a bakery and you have two ads, one for cake recipes and one for carrot cake recipes. Now, obviously, you want only the cake recipe to show up when someone searches “cake recipe” or something similar, not when they search “carrot cake recipe” – you have a separate ad for that for a reason! So what you can do is make the word “carrot” a negative for your cake recipe ad.

This concept of negatives is useful for any circumstance where you don’t want your ad to show up – including because the keyword has a low conversion rate. And this is what this project is about.

This project involves taking a list of search terms and finding individual words which are always associated with a lack of conversions over an extended period of time and bringing them to the attention of the marketers running the ad campaigns so they can negative them. Therefore, it involves taking a table with a column of strings and a column of ints and isolating individual words (separated by spaces) which are associated with, and only with, int values of 0.

I considered a wide variety of possible algorithms in the course of working on this problem but ultimately wanted to find something which had a minimal time complexity and could run moderately quickly over tens of thousands of data points (six months or more worth of keywords and conversions).

I wanted to make sure I was looping through the dataset as few times as possible, so I would make sure to fetch the data, only store what I would absolutely need, and store it in a separate array so I didn’t have to deal with the hassle of deleting elements and having the machine shift everything else back, since I was liable to do a lot of deletions.

I will admit that this problem took me a long while to crack. I had too hard a time visualizing a massive dataset with so many different terms to think about doing any logically complicated data manipulations to it. So my first step was to simplify it to a little table, like this:

`Strings | Ints"a x"   | 0"a y"   | 1"b x"   | 0"b y"   | 1`

Abstracting away everything but the bare bones of the problem helped me finally realize what I succinctly described at the beginning of this essay, that I wanted to find all the elements with, and only with, an int (# of conversions) value of 0.

Once I removed that block, the ideas started pouring out. I went through about twenty different possibilities before settling on this basic concept:

1. Fetch the data from an Excel spreadsheet to a Pandas DataFrame.
2. Loop through the DataFrame, splicing each individual search term and splitting it into component words.
3. Add each word associated with the number of conversions of the search term it’s a part of into another array, in alphabetical order.
4. For each word in the resulting array, while the word is equal to the one in the next row after it, check if all conversion values are equivalent to each other and to 0.
5. If they are, add the word to the final array; as soon as they’re not, skip to the next word and run that through step 4.

Now what’s left is to actually implement that. *exaggerated sigh*

What did you think of this post and this algorithm? Is it a good idea? Did I screw something up colossally? Please let me know in the comments below!

## If You Want to Be a Digital Marketer, Learn Web Development

I ended up in marketing nearly by accident. My plan was always to be a developer—it still is—but I knew I eventually wanted to start a company, and I so I knew that I would at some point need to learn a bunch of other stuff in addition to pure programming: sales, marketing, economics, accounting, business law. So when I was offered a marketing job, despite a work history full of building websites by hand and utterly lacking in anything even containing the letters “SEO”, I took it.

This gave me an interesting background for a marketer, where though I was extremely junior, I understood all the technical jargon that made my coworkers flinch. And looking back, I think my technical background was a boon to me; so much so that I recommend taking at least one beginner web development class to anyone who wants to be a digital marketer.

## Why Learn Web Dev?

Knowing web development is so useful for digital marketing because the two are hopelessly intertwined. For example, take the two most important pieces of metadata for SEOs: the meta title and description tags. Knowing where they are in the code, how they show up on the SERP, and how Google indexes them is extremely helpful to use them effectively for on-page SEO. Take another example: it’s all well and good to know by rote that appropriately sized images will make your page load faster, but if you understand the reason—that CSS takes a moment to resize the image, and if you give it an appropriately-sized image, it can prepare it faster—you’ll know exactly how to fix the problem. In general, being able to read the code when you “view source” on a webpage, along with knowing the general architecture of the internet, will help you immensely.

If you’re currently working in marketing or you’re planning to start soon, you may be thinking, “okay, in theory that sounds nice, but I’m already working so hard on marketing itself, and I don’t have time to learn to code – isn’t it super time-consuming and hard?” Fortunately for you, the answer is no, it’s not harder than any other marketing skill – if you have the right resource. And I have the right resource for you right here: HTML, CSS, and JavaScript Web Publishing by Colburn, Kyrnin, and Lemay. This book taught me a majority of what I know about HTML and CSS, which says at least something given my portfolio. It has one oddity: it doesn’t tell you how to actually host your site on the web until chapter 24. You’ll want to read that chapter very early on – probably either right before or right after chapter 1. Getting used to pushing your changes live with FTP is both easy (you can teach it to a 7-year-old) and important. Besides that little quirk, this is one of the best resources I have ever found for HTML/CSS/JS, and definitely the most useful for beginners. It even has a nice section on SEO at the end!

## Learn to Use Chrome’s Developer Tools

Besides building your own websites, there is a techie tool that’s also helpful if you’re going into digital marketing: Google Chrome’s Developer Tools (or “DevTools”).

You can access the Developer Tools by clicking the three dots in the top right-hand corner of the Chrome browser, then selecting “More Tools” about 3/4 of the way down the menu, then selecting “Developer Tools” from the bottom of the next menu. The developer tools are a window that pops out from the right-hand side of the screen, and they’ll let you do all sorts of awesome stuff, including seeing in real time in a real browser what would happen if you made certain edits, without ever changing the real source code. You can do this with not only your own website, but with other peoples’ sites, even those which are way more complicated than yours. Here’s a nice tutorial to get you started with Google DevTools.

These tools are very useful for the beginner web developer or digital marketer because they’ll let you toy around with massive, complex sites without having to build those sites from the ground up yourself. I tend to just open the DevTools on random websites and play around with making changes to see what they do. It’s not a systematic process, but it’ll improve your web development skills, and it’ll also be fun. Who said work couldn’t also be play?

Do you agree that digital marketers should learn to code? Do you have more useful tools for beginner web devs (those who are or aren’t marketers by trade)? Let me know in the comments!