MARKETING
12 of the Best WordPress Popup Plugins in 2023

Despite their overwhelmingly bad reputation, popups are a useful tool, but high conversion potential is not worth sacrificing user experience. Luckily, with the right WordPress popup plugins, you can leverage the high-conversion potential of popups without driving users away.)
Before diving into the tools, let’s look at the features to determine if a plugin suits your needs.
What to look for in a WordPress Popup Plugin
Popup plugins offer many features — from customization to screen display locations and built-in analytics — but the most important features to watch out for are targeting and trigger options.
Targeting refers to where the popup will appear on your website and who it will be shown to. Popular ways to target users with popups include page-level targeting, geolocation, device, and traffic source.
Triggers are actions that a user needs to take for the popup to appear. Popular trigger options include page entrance, scroll depth, clicks, time on page, and exit intent.
Having a few popup forms on your WordPress website could boost your lead capturing game. A quick Google search shows that there are many tools to choose from. To help you sort through the clutter and find a tool that moves the needle for your team, we’ll take a look at 12 WordPress popup plugins you should consider below.
Best WordPress Popup Plugins
- HubSpot WordPress Plugin
- OptinMonster
- Elementor Popups
- Sumo List Builder
- PopUp Domination
- MailOptin
- Ninja Popups
- Icegram
- Popup Maker
- Bloom Email Opt-Ins
- Popup Builder
- Poptin
1. HubSpot WordPress Plugin
HubSpot’s plugin allows you to connect your WordPress website to your HubSpot account for seamless integration. Any changes made to your popups in your HubSpot portal will be automatically reflected on your WordPress website without any extra work on your part.

HubSpot’s popup tool is highly intuitive and easy to use. You are first prompted to select the type of popup you want (box, banner, or slide-in) and then taken to the customizer where you can edit the text, add an image and relevant form fields, and even design your own thank-you message at the end.
Every contact you capture is automatically added to your free HubSpot CRM account. You can also target users by simply typing in the URL of the page(s) you want your popup to show up on and choose whether you want it to be triggered by a 50% page scroll, exit intent, or time elapsed. And if users decide to dismiss your popup, you can choose when they will be exposed to it again.
All the features in this tool are free.
What We Like: Other than the obvious reason being that this is our plugin, we love it for all it offers for free. This is an all-in-one plugin that handles everything you need on WordPress. With popups, you can create or manage your pre-existing popups with little to no hassle.
2. OptinMonster
OptinMonster was one of the firsts to popularize the use of popup forms in the marketing space. Its drag-and-drop feature makes it highly easy to use. You can choose from a variety of pre-built templates or create your own popup from scratch. Their Canvas feature allows you to create any type of popup (not just forms!) with the use of custom HTML/CSS and WordPress shortcodes.
Small Success is another unique feature that lets you display different offers to people who have already converted on one of your popups so you won’t annoy your visitors by showing them forms they’ve already signed up for. You gain access to plenty of triggers, such as exit intent, time on page, user inactivity, clicks, as well as many advanced targeting options like new vs returning visitor, cookie, geolocation, device, adblock usage, and more.

The main drawback with this plugin is that there is no free version. Plans start at $9/month, but you will need to upgrade to a higher tier for the more advanced features like A/B testing and exit intent.
What We Like: This is the best option for easy customizability. You have drag-and-drop for design, different templates to work off of, or even the ability to design from scratch. You’ll easily be able to with any type of popup you want to make with this plugin.
3. Elementor Popups
Design stunning popups with the popular page builder plugin Elementor and their Popup Builder feature. Elementor Popups uses the same interface as the page builder, allowing you to apply the same widgets and styling options to your popups, like buttons, countdown timers, email opt-in forms, and more. Similarly to many of the other plugins, this one offers a variety of popup forms like fly-ins and full-screen overlays.
With more than 100 beautiful templates to choose from, this popup builder lets you create WordPress specific page targeting options (categories, tags, post formats, etc.) with several triggers to choose from, such as click, time, scroll, inactivity, and exit intent.

This plugin does not come with built-in analytics or A/B split testing. And while the Elementor page builder plugin is free to use, this popup builder is only available when you purchase the pro version, which costs $49 for one website, and up to $199 for unlimited sites.
What We Like: Elementor’s popup plugin is a great choice for premium designers. You won’t need any coding experience to create stunning popups for your users. This is another all-in-one plugin that helps you build
4. Sumo List Builder
Sumo is more than just a popup form builder. On top of growing your email list, this plugin also helps with your social media, link building, and site analytics. The app has a module called List Builder, which allows you to create popups. You can set you popups to show up according to traffic source or different triggers such as clicks, time on page, exit intent and scroll depth.

Though this plugin comes with a free version, only one template is available in the free tier and you’ll need to upgrade to remove the Sumo branding. Premium plans start at $29/month, which puts Sumo on the more expensive side compared to other popup plugins.
What We Like: This plugin is great for building your email list. You have an intuitive integration with email and e-commerce, making this the perfect plugin for anyone looking to grow their business through email marketing.
5. PopUp Domination
PopUp Domination is one of the oldest popup tools out there. However, this hasn’t stopped them from making the right updates to stay competitive on the market. Its visual interface still makes it fairly easy to customize one of the 100+ pre-built templates available.
This plugin lets you show your popup to different users based on time on page, user inactivity, exit intent, clicks, total time on website, and mouse hover. On top of page-level targeting, more advanced targeting options include geolocation, traffic source, and device.

PopUp Domination has a royalty rate pricing structure. Each tier grants you access to all the features: unlimited domains and popups, A/B testing, live chat support, and more. Instead of being charged to have access to more features, you’re charged based on the number of total views your popups get across all of your websites.
If you want to use your popups on many websites that have low traffic, PopUp Domination might be a good solution. However, this may not be the best option for you if you have very few sites with high traffic volumes.
What We Like: This plugin is great for beginners since you will have many resources to help you use the tool and a relatively low price for getting started. Once your website starts getting more subscribers, however, you might want to look toward pivoting toward a more price-friendly option for your popup ads.
6. MailOptin
MailOptin is a fast-growing popup plugin for WordPress. It converts your website visitors into email subscribers using different types of opt-in forms including popups, notification bars, inline or embedded forms, scroll boxes, slide-ins, sidebar forms etc.
It is intuitive and easy to you in part because it uses the WordPress Customizer that you already know and love. It ships with a ton of professionally designed and mobile responsive templates to choose from.
It includes a number of display triggers such as page-level targeting, exit intent, time on site, pageviews, scroll trigger, adblock and referral detection, device targeting, new versus returning visitors etc. And integrates with all major email marketing providers and CRMs including Hubspot.
MailOptin is freemium. You can try out the plugin for free by downloading the lite version on WordPress.org repository or purchase a premium license to unlock more powerful features and top-notch customer support.
What We Like: This popup plugin integrates well with WordPress since you work directly through WordPress customizer. This can be great for people familiar with WordPress and just want something that works.
7. Ninja Popups
Ninja Popups is one of CodeCanyon’s top selling plugins. For $24, you gain access to their drag-and-drop popup builder with over 70 templates and animation effects to choose from.
And if you want more than just forms, Ninja Popups lets you create all kinds of popups, such as video displays and social sharing boxes. Its anti-adblocker technology lets you show your popups even to visitors who use ad blockers. This plugin also offers page-level targeting, and trigger options include scroll depth, time on page, exit intent, and user inactivity.

Although there is no free version, at only $24, Ninja Popups offers some of the most creative freedom for the price.
What We Like: This plugin is effective and enables your creativity. Bypassing adblockers is especially helpful considering 2 in 5 people use adblock today.
8. Icegram
If you’re looking for a more native option, Icegram lets you create popups right from the WordPress dashboard, thought its text-based interface makes it slightly less user friendly than most. Icegram’s trigger options include time on page, exit intent, user inactivity, clicks, and time delay. Targeting options include page, user retargeting, device, and geolocation.

This plugin offers a fair amount of value for free, but to access more functionalities, you will want to upgrade. Premium plans start at $97/year.
What We Like: This plugin is another great choice for working directly through WordPress. If you can get past the text-based interface, this is a good option for those needing a simple popup ad solution.
9. Popup Maker
Popup Maker offers a lot of flexibility in terms of what you can build. In addition to opt-in forms, you can create cookie notices, video lightboxes, notification boxes, etc.
A big draw of this plugin is its WooCommerce integration, which lets you target users based on their shopping cart items, purchase data, and more. However, this plugin’s lack of a visual editor makes it less friendly to use.

You can use Popup Maker for free, but for more functionality, individual extensions can be purchased starting at $87 per year
What We Like: This plugin lets you tailor your website popup ads to your user. You also have a good set of basic options to work off of as mentioned. Popup Maker is another good choice for those who are familiar with WordPress and just want a simple way to add popups to their page. The extra benefit is being able to work off of consumer data.
10. Bloom Email Opt-Ins
Provided to you by the devs at Elegant Themes (authors of the popular Divi theme), Bloom comes with over 100 templates to customize and lets you create a variety of forms on top of popups, including widgets, inline boxes, and optin lockers which you can use for gated content. Along with basic page targeting, this plugin contains unique trigger options — for example, make a popup appear after a user has left a comment on your page or after a user has made a purchase.

Despite its high-quality templates and beautiful dashboard, Bloom lacks a lot of the advanced features other plugins offer like an exit intent trigger option, and it doesn’t have a visual customizer.
Because this plugin comes from Elegant Theme, you can only access it by purchasing an Elegant Theme subscription, which costs $89/year or $249 for lifetime support and updates. This subscription also gives you access to 87 premium themes and 2 other plugins. But if all you’re looking for is a popup plugin, this may not be worth the investment.
What We Like: Bloom Email Opt-ins is a great choice for people who need more than just a popup plugin. You can fully customize your website through this plugin, and that includes popup ads.
11. Popup Builder
Popup Builder lets you insert any type of content into your popups and create custom animation effects. It offers features like automatic closing, user retargeting, and time delay triggers, as well as integrations with email service providers MailChimp and AWeber.
While this plugin can be used for free, just like Popup Maker, you will need to purchase extensions for additional functionality. Individual extension prices vary between $5 and $15, but you can get the full bundle starting at $49/month.
What We Like: Popup builder is a good option for those wanting to make mobile-friendly popup ads. Its intuitive user experience lets you build great looking popups in seconds.
12. Poptin
Poptin is a free popup and form builder specially designed for marketers, website owners, and digital agencies. Its powerful conversion optimization features are effective in boosting email signups, reducing cart abandonment, increasing engagement, and improving your overall sales conversion rate. It has a variety of fully responsive and customizable popup and forms templates that you can utilize without the need for coding.
In a matter of minutes, you can create your lightbox popups, full-screen overlays, gamified popups, countdown popups, slide-ins, bars, widgets, email forms, and more. You can add different elements such as images, videos, icons, countdown timer, coupons, and even custom CSS. The best part is that you can Integrate it with HubSpot CRM and emailing software to experience a seamless lead generation funnel. Poptin also offers a wide range of smart triggers and targeting rules to better convert the most qualified leads and customers.
Poptin’s free plan already includes major tools and features like analytics, A/B testing, exit-intent trigger, unlimited popups, and forms, among others. If you want to get access to more advanced features, you can always upgrade to its paid plans which start at only $25 per month.
What We Like: This plugin gives you a lot of bang for your buck. While other plugins on this list charge you for access to analytics, this tool gives you all of that for free. Poptin is best for marketers looking to add popups and dive into the data behind what makes them effective.
Choose whichever plugin fits your needs the best.
There are endless options when it comes to WordPress popup tools.
If you’re looking for a quick and easy way to collect user information and convert leads, check out HubSpot’s free form popup WordPress plugin. Installing the plugin will automatically connect your demand capture tools to the free HubSpot CRM so you can easily create follow-up emails for people who have filled out your form, track their activity on your site, and manage your leads all in one place.
MARKETING
Mnemonic Content Strategy Framework Can Spark Conversations

I’m a sucker for mnemonics.
In fact, I remember how to spell it by “Me Nomics Except M nOt N In Case Spelling.”
OK, that’s a lie. But I daresay ChatGPT could never come up with that.
Anyway, one of my favorite idea-remembering devices comes from my hero Philip Kotler. He reduces his perfect definition of marketing to CCDVTP – Create and Communicate Value to a Target at a Profit.”
I lean on that mnemonic device when anyone asks about the best definition of marketing’s function in a business.
However, what makes a great mnemonic like CCDVTP is that each word the letter represents has something deeper behind it. So it’s not just six words – it’s six operating concepts with definitions made easier to remember by just remembering how the six words go together.
A mnemonic device for content strategy
I’ve written about the standard framework for developing or strengthening your content strategy. It’s one of the core modules of a CMI University course. It can be a lot to take in because the framework’s concepts and definitions need to be explained in varying levels of detail.
So, recently, I created a mnemonic device to use in my explanation – the 5 Cs: Coordination and Collaboration produce Content before Containers and make Channels measurable.
5Cs of #ContentStrategy: Coordination and Collaboration produce Content before Containers and make Channels measurable via @Robert_Rose @CMIContent. Click To Tweet
It works as a core or high-level definition of a content marketing strategy. But, like Kotler’s CCDVTP, it also lets me drill into the framework’s five concepts or pressure points. Let me explain:
Coordination
The primary purpose of a content strategy is to develop and manage core responsibilities and processes. In addition, they allow marketing to build and continually assess resource allocation, skill sets, and charters the marketing team needs to make content a business strength.
Most businesses that lack this C struggle with content as a repeatable or measurable approach. As I’ve said, content is everyone’s job in many businesses and no one’s strategy. A key element of a content strategy is a focus on building coordination into how ideas become content and ultimately generate business value.
Most businesses that lack coordination struggle with making #content a repeatable and measurable approach, says @Robert_Rose. Click To Tweet
Collaboration
In many businesses, content is developed in silos, especially with sales and marketing. Sometimes, it may be divided by channel – web, email, and sales teams don’t work together. In other cases, it may be by function – PR, sales, marketing, brand, and demand generation have different approaches.
Content is a team sport. The practitioners’ job is not to be good at content but to enable the business to be good at content. Scalability only happens through an effective, collaborative approach to transforming ideas into content and content into experiences.
Content before containers
As marketers, you are trained to think container first and content second. You start with “I need a web page,” “I need an email,” or “I need a blog post.” Then, your next step is to create content specific to that container.
If you start with “I need a blog post” and then create the #content idea, you’re doing it wrong, says @Robert_Rose via @CMIContent. Click To Tweet
I can’t tell you how many big ideas I’ve seen trapped in the context of a blog post simply because that was how it was conceived. I’ve also seen the reverse – small ideas spun into an e-book or white paper because someone wanted that digital asset.
This pressure point requires reverse thinking about your business’ process to create content. The first step must be to create fully formed ideas (big and small) and then (and only then) figure out which containers and how many might be appropriate.
My test to see whether marketing teams put content before containers is to look at their request or intake form. Does it say, “What kind of content do you need?” and list options, such as email, white paper, e-book, and brochure? Or does it say, “Please explain the idea or story you’d like to develop more fully?”
Channels
I purposely put channels last because they express the kind of content you create. Channels dictate how you ultimately reach the customers and how the customers will access your content. Which or how many of your content channels do you treat as a media company would?
Is your corporate blog truly centered on the audience, or is it centered on your product or brand? Is it a repository where you put everything from news about your product and how to use it to what to expect in the future and how other customers use your product?
What about your social media, website, newsletters, and thought leadership center? What is their purpose and editorial strategy? How do you evolve your content products as your audience changes as a media company does? Without a clear strategy for every channel, the measurement of content becomes guesswork at best.
When you examine your strategic approach to content, I hope the 5Cs mnemonic device helps you have those necessary conversations around coordination, collaboration, content before containers, and channels with the stakeholders in your business.
It’s your story. Tell it well.
HANDPICKED RELATED CONTENT:
Cover image by Joseph Kalinowski/Content Marketing Institute
MARKETING
The Moz Links API: An Introduction

What exactly IS an API? They’re those things that you copy and paste long strange codes into Screaming Frog for links data on a Site Crawl, right?
I’m here to tell you there’s so much more to them than that – if you’re willing to take just a few little steps. But first, some basics.
What’s an API?
API stands for “application programming interface”, and it’s just the way of… using a thing. Everything has an API. The web is a giant API that takes URLs as input and returns pages.
But special data services like the Moz Links API have their own set of rules. These rules vary from service to service and can be a major stumbling block for people taking the next step.
When Screaming Frog gives you the extra links columns in a crawl, it’s using the Moz Links API, but you can have this capability anywhere. For example, all that tedious manual stuff you do in spreadsheet environments can be automated from data-pull to formatting and emailing a report.
If you take this next step, you can be more efficient than your competitors, designing and delivering your own SEO services instead of relying upon, paying for, and being limited by the next proprietary product integration.
GET vs. POST
Most APIs you’ll encounter use the same data transport mechanism as the web. That means there’s a URL involved just like a website. Don’t get scared! It’s easier than you think. In many ways, using an API is just like using a website.
As with loading web pages, the request may be in one of two places: the URL itself, or in the body of the request. The URL is called the “endpoint” and the often invisibly submitted extra part of the request is called the “payload” or “data”. When the data is in the URL, it’s called a “query string” and indicates the “GET” method is used. You see this all the time when you search:
https://www.google.com/search?q=moz+links+api <-- GET method
When the data of the request is hidden, it’s called a “POST” request. You see this when you submit a form on the web and the submitted data does not show on the URL. When you hit the back button after such a POST, browsers usually warn you against double-submits. The reason the POST method is often used is that you can fit a lot more in the request using the POST method than the GET method. URLs would get very long otherwise. The Moz Links API uses the POST method.
Making requests
A web browser is what traditionally makes requests of websites for web pages. The browser is a type of software known as a client. Clients are what make requests of services. More than just browsers can make requests. The ability to make client web requests is often built into programming languages like Python, or can be broken out as a standalone tool. The most popular tools for making requests outside a browser are curl and wget.
We are discussing Python here. Python has a built-in library called URLLIB, but it’s designed to handle so many different types of requests that it’s a bit of a pain to use. There are other libraries that are more specialized for making requests of APIs. The most popular for Python is called requests. It’s so popular that it’s used for almost every Python API tutorial you’ll find on the web. So I will use it too. This is what “hitting” the Moz Links API looks like:
response = requests.post(endpoint, data=json_string, auth=auth_tuple)
Given that everything was set up correctly (more on that soon), this will produce the following output:
{'next_token': 'JYkQVg4s9ak8iRBWDiz1qTyguYswnj035nqrQ1oIbW96IGJsb2dZgGzDeAM7Rw==', 'results': [{'anchor_text': 'moz', 'external_pages': 7162, 'external_root_domains': 2026}]}
This is JSON data. It’s contained within the response object that was returned from the API. It’s not on the drive or in a file. It’s in memory. So long as it’s in memory, you can do stuff with it (often just saving it to a file).
If you wanted to grab a piece of data within such a response, you could refer to it like this:
response['results'][0]['external_pages']
This says: “Give me the first item in the results list, and then give me the external_pages value from that item.” The result would be 7162.
NOTE: If you’re actually following along executing code, the above line won’t work alone. There’s a certain amount of setup we’ll do shortly, including installing the requests library and setting up a few variables. But this is the basic idea.
JSON
JSON stands for JavaScript Object Notation. It’s a way of representing data in a way that’s easy for humans to read and write. It’s also easy for computers to read and write. It’s a very common data format for APIs that has somewhat taken over the world since the older ways were too difficult for most people to use. Some people might call this part of the “restful” API movement, but the much more difficult XML format is also considered “restful” and everyone seems to have their own interpretation. Consequently, I find it best to just focus on JSON and how it gets in and out of Python.
Python dictionaries
I lied to you. I said that the data structure you were looking at above was JSON. Technically it’s really a Python dictionary or dict datatype object. It’s a special kind of object in Python that’s designed to hold key/value pairs. The keys are strings and the values can be any type of object. The keys are like the column names in a spreadsheet. The values are like the cells in the spreadsheet. In this way, you can think of a Python dict as a JSON object. For example here’s creating a dict in Python:
my_dict = { "name": "Mike", "age": 52, "city": "New York" }
And here is the equivalent in JavaScript:
var my_json = { "name": "Mike", "age": 52, "city": "New York" }
Pretty much the same thing, right? Look closely. Key-names and string values get double-quotes. Numbers don’t. These rules apply consistently between JSON and Python dicts. So as you might imagine, it’s easy for JSON data to flow in and out of Python. This is a great gift that has made modern API-work highly accessible to the beginner through a tool that has revolutionized the field of data science and is making inroads into marketing, Jupyter Notebooks.
Flattening data
But beware! As data flows between systems, it’s not uncommon for the data to subtly change. For example, the JSON data above might be converted to a string. Strings might look exactly like JSON, but they’re not. They’re just a bunch of characters. Sometimes you’ll hear it called “serializing”, or “flattening”. It’s a subtle point, but worth understanding as it will help with one of the largest stumbling blocks with the Moz Links (and most JSON) APIs.
Objects have APIs
Actual JSON or dict objects have their own little APIs for accessing the data inside of them. The ability to use these JSON and dict APIs goes away when the data is flattened into a string, but it will travel between systems more easily, and when it arrives at the other end, it will be “deserialized” and the API will come back on the other system.
Data flowing between systems
This is the concept of portable, interoperable data. Back when it was called Electronic Data Interchange (or EDI), it was a very big deal. Then along came the web and then XML and then JSON and now it’s just a normal part of doing business.
If you’re in Python and you want to convert a dict to a flattened JSON string, you do the following:
import json my_dict = { "name": "Mike", "age": 52, "city": "New York" } json_string = json.dumps(my_dict)
…which would produce the following output:
'{"name": "Mike", "age": 52, "city": "New York"}'
This looks almost the same as the original dict, but if you look closely you can see that single-quotes are used around the entire thing. Another obvious difference is that you can line-wrap real structured data for readability without any ill effect. You can’t do it so easily with strings. That’s why it’s presented all on one line in the above snippet.
Such stringifying processes are done when passing data between different systems because they are not always compatible. Normal text strings on the other hand are compatible with almost everything and can be passed on web-requests with ease. Such flattened strings of JSON data are frequently referred to as the request.
Anatomy of a request
Again, here’s the example request we made above:
response = requests.post(endpoint, data=json_string, auth=auth_tuple)
Now that you understand what the variable name json_string is telling you about its contents, you shouldn’t be surprised to see this is how we populate that variable:
data_dict = { "target": "moz.com/blog", "scope": "page", "limit": 1 } json_string = json.dumps(data_dict)
…and the contents of json_string looks like this:
'{"target": "moz.com/blog", "scope": "page", "limit": 1}'
This is one of my key discoveries in learning the Moz Links API. This is in common with countless other APIs out there but trips me up every time because it’s so much more convenient to work with structured dicts than flattened strings. However, most APIs expect the data to be a string for portability between systems, so we have to convert it at the last moment before the actual API-call occurs.
Pythonic loads and dumps
Now you may be wondering in that above example, what a dump is doing in the middle of the code. The json.dumps() function is called a “dumper” because it takes a Python object and dumps it into a string. The json.loads() function is called a “loader” because it takes a string and loads it into a Python object.
The reason for what appear to be singular and plural options are actually binary and string options. If your data is binary, you use json.load() and json.dump(). If your data is a string, you use json.loads() and json.dumps(). The s stands for string. Leaving the s off means binary.
Don’t let anybody tell you Python is perfect. It’s just that its rough edges are not excessively objectionable.
Assignment vs. equality
For those of you completely new to Python or programming in general, what we’re doing when we hit the API is called an assignment. The result of requests.post() is being assigned to the variable named response.
response = requests.post(endpoint, data=json_string, auth=auth_tuple)
We are using the = sign to assign the value of the right side of the equation to the variable on the left side of the equation. The variable response is now a reference to the object that was returned from the API. Assignment is different from equality. The == sign is used for equality.
# This is assignment: a = 1 # a is now equal to 1 # This is equality: a == 1 # True, but relies that the above line has been executed
The POST method
response = requests.post(endpoint, data=json_string, auth=auth_tuple)
The requests library has a function called post() that takes 3 arguments. The first argument is the URL of the endpoint. The second argument is the data to send to the endpoint. The third argument is the authentication information to send to the endpoint.
Keyword parameters and their arguments
You may notice that some of the arguments to the post() function have names. Names are set equal to values using the = sign. Here’s how Python functions get defined. The first argument is positional both because it comes first and also because there’s no keyword. Keyworded arguments come after position-dependent arguments. Trust me, it all makes sense after a while. We all start to think like Guido van Rossum.
def arbitrary_function(argument1, name=argument2): # do stuff
The name in the above example is called a “keyword” and the values that come in on those locations are called “arguments”. Now arguments are assigned to variable names right in the function definition, so you can refer to either argument1 or argument2 anywhere inside this function. If you’d like to learn more about the rules of Python functions, you can read about them here.
Setting up the request
Okay, so let’s let you do everything necessary for that success assured moment. We’ve been showing the basic request:
response = requests.post(endpoint, data=json_string, auth=auth_tuple)
…but we haven’t shown everything that goes into it. Let’s do that now. If you’re following along and don’t have the requests library installed, you can do so with the following command from the same terminal environment from which you run Python:
pip install requests
Often times Jupyter will have the requests library installed already, but in case it doesn’t, you can install it with the following command from inside a Notebook cell:
!pip install requests
And now we can put it all together. There’s only a few things here that are new. The most important is how we’re taking 2 different variables and combining them into a single variable called AUTH_TUPLE. You will have to get your own ACCESSID and SECRETKEY from the Moz.com website.
The API expects these two values to be passed as a Python data structure called a tuple. A tuple is a list of values that don’t change. I find it interesting that requests.post() expects flattened strings for the data parameter, but expects a tuple for the auth parameter. I suppose it makes sense, but these are the subtle things to understand when working with APIs.
Here’s the full code:
import json import pprint import requests # Set Constants ACCESSID = "mozscape-1234567890" # Replace with your access ID SECRETKEY = "1234567890abcdef1234567890abcdef" # Replace with your secret key AUTH_TUPLE = (ACCESSID, SECRETKEY) # Set Variables endpoint = "https://lsapi.seomoz.com/v2/anchor_text" data_dict = {"target": "moz.com/blog", "scope": "page", "limit": 1} json_string = json.dumps(data_dict) # Make the Request response = requests.post(endpoint, data=json_string, auth=AUTH_TUPLE) # Print the Response pprint(response.json())
…which outputs:
{'next_token': 'JYkQVg4s9ak8iRBWDiz1qTyguYswnj035nqrQ1oIbW96IGJsb2dZgGzDeAM7Rw==', 'results': [{'anchor_text': 'moz', 'external_pages': 7162, 'external_root_domains': 2026}]}
Using all upper case for the AUTH_TUPLE variable is a convention many use in Python to indicate that the variable is a constant. It’s not a requirement, but it’s a good idea to follow conventions when you can.
You may notice that I didn’t use all uppercase for the endpoint variable. That’s because the anchor_text endpoint is not a constant. There are a number of different endpoints that can take its place depending on what sort of lookup we wanted to do. The choices are:
-
anchor_text
-
final_redirect
-
global_top_pages
-
global_top_root_domains
-
index_metadata
-
link_intersect
-
link_status
-
linking_root_domains
-
links
-
top_pages
-
url_metrics
-
usage_data
And that leads into the Jupyter Notebook that I prepared on this topic located here on Github. With this Notebook you can extend the example I gave here to any of the 12 available endpoints to create a variety of useful deliverables, which will be the subject of articles to follow.
MARKETING
What Businesses Get Wrong About Content Marketing in 2023 [Expert Tips]
![What Businesses Get Wrong About Content Marketing in 2023 [Expert Tips] What Businesses Get Wrong About Content Marketing in 2023 [Expert Tips]](https://articles.entireweb.com/wp-content/uploads/2023/05/What-Businesses-Get-Wrong-About-Content-Marketing-in-2023-Expert.pngkeepProtocol.png)
The promise of inbound marketing is a lure that attracts businesses of all kinds, but few understand the efforts it takes to be successful. After a few blog posts, they flame out and grumble “We tried content marketing, but it didn’t really work for us.” I hear this from prospective clients all the time.
-
SEO5 days ago
Event Link Building: A Beginner’s Guide
-
SEO5 days ago
How To Use Search Console Bulk Data Export
-
SEARCHENGINES5 days ago
Google Search Suggestions For Your Search
-
SEARCHENGINES5 days ago
Google Search Algorithm Ranking Volatility May 22 & 23
-
SEARCHENGINES5 days ago
Google Job Search Bug
-
SEO5 days ago
Optimizing News Sites Using Google Search Console Reports
-
SOCIAL5 days ago
YouTube’s Retiring YouTube Stories Next Month
-
TECHNOLOGY6 days ago
How Optical And Intelligent Character Recognition Works And Its Benefits