You might be doing basic stuff, like copying and pasting text on spread sheets, you might be running large scale automated platforms with sophisticated algorithms, or somewhere in between. In any case your job is all about working with data.
I have a tutorial on DataCamp that demonstrates a real-life example of how to use Python for creating a Search Engine Marketing campaign. There is also a project to practice those skills in an agency / case study setting.
I also have an interactive tool based on this package, where you can generate keyword combinations easily.
- Generate keywords: starting from a list of products, and a list of words that might make sense together, you can generate a full table of many possible combinations and permutations of relevant keywords for that product. The output is a ready-to-upload table to get you started with keywords.
>>> import advertools as adv
>>> adv.kw_generate(products=['toyota'],
words=['buy', 'price'],
match_types=['Exact']).head()
... Campaign Ad Group Keyword Criterion Type
0 SEM_Campaign toyota toyota buy Exact
1 SEM_Campaign toyota toyota price Exact
2 SEM_Campaign toyota buy toyota Exact
3 SEM_Campaign toyota price toyota Exact
4 SEM_Campaign toyota toyota buy price Exact
- Create ads: Two main ways to create text ads, one is from scratch (bottom-up) and the other is top down (given a set of product names).
- From scratch: This is the traditional way of writing ads. You have a template text, and you want to insert the product name dynamically in a certain location. You also want to make sure you are within the character limits. For more details, I have a tutorial on how to create multiple text ads from scratch.
>>> ad_create(template='Let\'s count {}',
replacements=['one', 'two', 'three'],
fallback='one', # in case the total length is greater than max_len
max_len=20)
["Let's count one", "Let's count two", "Let's count three"]
>>> ad_create('My favorite car is {}', ['Toyota', 'BMW', 'Mercedes', 'Lamborghini'], 'great', 28)
['My favorite car is Toyota', 'My favorite car is BMW', 'My favorite car is Mercedes',
'My favorite car is great'] # 'Lamborghini' was too long, and so was replace by 'great'
- Top-down approach: Sometimes you need to start with a given a list of product names, which you can easily split them into the relevant ad slots, taking into consideration the length restrictions imposed by the ad platform. Imagine having the following list of products, and you want to split each into slots of 30, 30, and 80 characters (based on the AdWords template):
>>> products = [
'Samsung Galaxy S8+ Dual Sim 64GB 4G LTE Orchid Gray',
'Samsung Galaxy J1 Ace Dual Sim 4GB 3G Wifi White',
'Samsung Galaxy Note 8 Dual SIM 64GB 6GB RAM 4G LTE Midnight Black',
'Samsung Galaxy Note 8 Dual SIM 64GB 6GB RAM 4G LTE Orchid Grey'
]
>>> [adv.ad_from_string(p) for p in products]
... [['Samsung Galaxy S8+ Dual Sim', '64gb 4g Lte Orchid Gray', '', '', '', ''],
['Samsung Galaxy J1 Ace Dual Sim', '4gb 3g Wifi White', '', '', '', ''],
['Samsung Galaxy Note 8 Dual Sim', '64gb 6gb Ram 4g Lte Midnight', 'Black', '', '', ''],
['Samsung Galaxy Note 8 Dual Sim', '64gb 6gb Ram 4g Lte Orchid', 'Grey', '', '', '']]
- Analyze word frequency: Calculate the absolute and weighted frequency of words in a collection of documents to uncover hidden trends in the data. This is basically answering the question, ‘What did we write about vs. what was actually read?’ Here is a tutorial on DataCamp on measuring absolute vs weighted frequency of words.
- Extract important elements from social media posts: Get the more informative
- elements of social media posts (hashtags, mentions, emoji). You also get some basic statistics about them. Check out a more detailed tutorial on Kaggle, on how to extract entities from social media posts using these functions.
>>> posts = ['i like #blue', 'i like #green and #blue', 'i like all']
>>> hashtag_summary = adv.extract_hashtags(posts)
>>> hashtag_summary.keys()
dict_keys(['hashtags', 'hashtags_flat', 'hashtag_counts', 'hashtag_freq',
'top_hashtags', 'overview'])
what are the hashtags?
>>> hashtag_summary['hashtags']
[['#blue'], ['#green', '#blue'], []]
>>> hashtag_summary['top_hashtags']
[('#blue', 2), ('#green', 1)]
How many were there per post?
>>> hashtag_summary['hashtag_counts']
[1, 2, 0]
And you can do the same for mentions and emoji (with the textual name of each emoji).
pip install advertools
Function names mostly start with the object you are working on:
kw_
: for keywords-related functionsad_
: for ad-related functionsurl_
: URL tracking and generationextract_
: for extracting entities from social media posts (mentions, hashtags, emoji, etc.)twitter
: a module for querying the Twitter API and getting results in a pandas DataFrameserp_
: get search engine results pages in a DataFrame, currently available: Google and YouTube