One place for hosting & domains

      June 2021

      How to Fix the “Are You Sure You Want to Do This” Error in WordPress (4 Methods)

      Do you keep getting the “Are you sure you want to do this” error message while working on your WordPress site? You’re probably wondering what’s causing it and if there’s a way to get rid of it. This warning can be very frustrating, as it doesn’t really tell you what the problem is. Plus, it prevents you from performing basic tasks on your site, such as editing blog posts.

      The “Are you sure you want to do this” error can happen for several reasons. You may have installed a faulty plugin or theme, or you might be experiencing a security issue. Fortunately, you can determine the exact cause and fix the error in a few simple steps.

      In this post, we’ll look at the main causes of the “Are you sure you want to do this” error in WordPress and show you how to fix it using four methods. Let’s get started!

      What the “Are You Sure You Want to Do This” Error Is

      The “Are you sure you want to do this” issue usually crops up while you’re performing certain tasks on your WordPress site. For instance, you may be trying to publish a post or customize your theme when the error message appears, preventing you from completing the job.

      The “Are you sure you want to do this?” error in WordPress.

      WordPress uses security tokens, called nonces, to verify that you have the proper permissions to perform a particular action on the site. These nonces help protect your site against hacking attacks. Therefore, when the “Are you sure you want to do this” error message pops up on your screen, it means that WordPress was unable to recognize you as the rightful owner or user of your site.

      Various factors can trigger this verification failure. Next, we’ll take a look at the leading causes.

      Skip the Stress, Outsource to Us

      Avoid troubleshooting when you sign up for DreamPress. Our friendly WordPress experts are available 24/7 to help solve website problems — big or small.

      Potential Causes of the “Are You Sure You Want to Do This” Error

      The “Are you sure you want to do this” error message doesn’t pinpoint exactly what the problem is. However, we can narrow down the issue to a few causes.

      Below are four common reasons you may be seeing this error:

      1. You’ve selected an incorrect file when uploading a plugin or theme.
      2. You’re using a plugin or theme with incorrect code.
      3. You need to increase your PHP memory limit.
      4. You’re facing a security issue due to corrupted files.

      The most likely scenario is a faulty theme or plugin on your site. To figure out what is causing the issue, however, you’ll need to do some troubleshooting.

      How to Fix the “Are You Sure You Want to Do This” Error in WordPress (4 Methods)

      Now, let’s go through the four main methods for fixing this common WordPress error. Before proceeding, you may want to perform a backup of your site just in case something goes wrong and you need to restore an earlier version.

      1. Check Your Plugins

      As we mentioned earlier, the “Are you sure you want to do this” error could be caused by a faulty plugin on your site. To find out if this is the case, you can deactivate your plugins and reactivate them one by one.

      Note that for this step, you’ll need to access your site’s root directory using a Secure File Transfer Protocol (SFTP) client such as FileZilla or by logging into your web hosting account and using the file manager.

      If you have a DreamHost account, you can navigate to WordPress > Managed WordPress in the sidebar, find your domain, and select Manage.

      The DreamPress Manage screen.

      On the next page, click on the Manage Files button in the Details section. In the file manager, open the folder with your domain name.

      In your site’s root directory, locate and open the wp-content folder. To deactivate your plugins, you can find the plugins folder and rename it to “plugins_test”.

      Renaming the plugins folder in the site’s root directory.

      Return to your WordPress site. If the error message doesn’t reappear, you know that a plugin caused the issue.

      The next step is to find out which one is the culprit. First, navigate back to your site’s root directory and rename the plugins_test folder back to “plugins”.

      Next, go to the Plugins page in your WordPress dashboard. Activate the first plugin, and then check to see if the error is still present. Continue activating them one by one and testing your site until you find the plugin causing the error. Then you can replace it, or reach out to its developer for help.

      2. Switch to a Default WordPress Theme

      If deactivating your plugins doesn’t resolve the issue, it’s time to see if your current theme may be to blame. We’ll do this by switching to the default WordPress theme.

      Once again, you’ll need to access your site’s root directory. To switch to the default WordPress theme, you can open the wp-content folder, locate the themes folder, and then rename it to “themes_test”.

      Renaming the themes folder in the site’s root directory.

      After renaming the folder, your site will automatically revert to the default WordPress theme. To see if this solves the problem, return to your site and carry out the same tasks that caused it before.

      If the “Are you sure you want to do this” message doesn’t come up, your previous theme must have been at fault. As with your plugins, this means you may need to update or replace your theme (or get in touch with its developer for assistance).

      3. Increase Your PHP Memory Limit

      If disabling your plugins and switching themes didn’t do the trick, the issue might be your WordPress PHP memory limit. If your current limit is set too low, it can interrupt certain processes.

      There are various ways to go about this. If you’re a DreamHost user, you can increase your PHP memory limit by editing your phrc file. For other WordPress users, you can go through your php.ini or wp-config.php file.

      By default, the limit is set to 256M. However, you can add a line of code to the file to increase the limit. For example:

      memory_limit = 300M

      You can choose whatever value you wish. Save the file, and then reload the WordPress page displaying the error to see if this has resolved the problem.

      4. Replace All Your Core WordPress Files With Fresh Copies

      If the above three methods didn’t fix the error, it’s possible that some of your WordPress files became corrupted due to a recent malware or hacking attack. To confirm this, you can replace all of the WordPress core files with fresh copies.

      Again, we recommend that you perform a backup of your site first. When you’re done, you’ll need to access your site via an FTP client. While you can also use the file manager in your web hosting account for this method, it will be quicker to replace your site’s files using an FTP client.

      In the root directory, locate and download the wp-config.php file.

      Downloading the wp-config.php file from the root directory with the FTP client.

      Next, you can delete all WordPress files and folders in the root directory except for the wp-content folder, which contains your plugins, themes, and media. Then download the latest version of WordPress to your computer and extract the .zip file.

      Locate and copy the wp-config.php file you downloaded, and paste it in the extracted WordPress file.

      Adding the downloaded wp-config.php file in the WordPress folder.

      The final step is to upload the WordPress files on your computer to your site. These new files will replace the ones that we deleted in the root directory.

      If you’re using FileZilla, select every item in the WordPress file on your computer except the wp-content folder, and then right-click and select Upload.

      Uploading new WordPress files to your site’s root directory.

      The uploading process may take a few minutes. Once it is complete, you can return to your WordPress site, and the error message should be gone.

      Additional Troubleshooting Tutorials

      Do you want to learn how to resolve other website issues? We’ve put together several tutorials to help you troubleshoot some of the most common WordPress errors:

      Meanwhile, if you want more information about setting up and running a WordPress site, check out our WordPress Tutorials. There, you’ll find a collection of guides designed to help you navigate the WordPress dashboard like an expert.

      Take Your WordPress Website to the Next Level

      Whether you need help navigating the WordPress dashboard, fixing incorrect database credentials, or finding the plugins folder, we can help! Subscribe to our monthly digest so you never miss an article.

      Banish This WordPress Error Message

      The “Are you sure you want to do this” error may prevent you from performing basic WordPress tasks. While a faulty theme or plugin commonly causes it, it can also arise if you’ve reached your PHP memory limit or your site’s facing a security issue.

      To resolve the “Are you sure you want to do this” error, you can try these four solutions:

      1. Deactivate your plugins and reactivate them one at a time.
      2. Revert to the default WordPress theme.
      3. Increase your PHP memory limit.
      4. Replace all WordPress core files with fresh copies.

      Troubleshooting WordPress issues can be time-consuming. If you want to spend less time dealing with WordPress errors, you might want to consider switching to DreamPress. Our managed WordPress hosting plans come with full technical support for site owners, as well as daily backups to help keep your content safe.

      Source link

      The Website Owner’s Guide to Email Marketing

      Email is the sharpest tool in the box for building relationships, generating new customers, and increasing sales on your website. Here’s how to get started.

      Remember in 1998’s You’ve Got Mail when Meg Ryan‘s character waits impatiently for her dial-up internet to connect before typing an email to her virtual pen pal on a simple dialog box? Watch it now and cringe; we’ve come a long way, baby. 

      But while dial-up and AOL instant messaging are stuck in the stone ages of the internet, email isn’t, especially for you website owners out there — and here’s why.

      Email still has a very real place in society, with more than four billion email users worldwide, a number predicted to rise to 4.5 billion by 2024.

      New Email.jpeg

      Even though we tend to dread the sight of an overstuffed inbox, the reality is this: Email triumphs as a powerful tool of communication and persuasion for website owners and businesses. 

      And marketers understand this. 

      In fact, 89% of marketers say that email is their primary channel for lead generation. This seemingly-archaic medium is increasingly relevant — unlike screen names or Myspace pages — for website owners looking to build customer relationships and augment sales. 

      Marketers consistently rank email as the single-most-effective tactic for meeting their awareness, acquisition, conversion, and retention goals. They’ve branded it, fittingly, “the workhorse” and prove your marketing budget should include more $$$ allotted for an invested email strategy.

      And they’re not the only ones waving virtual foam fingers for email practices; more than half of consumers say they enjoy receiving emails from brands.

      But understand this: You don’t have to be a big-shot marketer to create and send email campaigns. Even beginners can use emails to generate slam-dunk sales or build a loyal blog following.

      So what exactly is email marketing? How can you encourage customers to sign up for your emails in the first place? Then, how do you craft sparkling newsletter copy while avoiding the spam folder? 

      Well, you’re in luck. We developed the Website Owner’s Guide to Email Marketing to help you understand and implement the fundamentals of email marketing. Read on and learn the ins-and-outs of segmentation, automation, sequencing, bounce rates, and how to craft that email your visitors are anxious to open:

      We promise it’s easier than dial-up.

      1. Email Marketing: Ground Level

      If you’re like 58% of adults, after waking up and resisting the urge to hit the snooze button, you’re rolling over groggily to grab your phone. Within seconds, you’re scanning your email inbox before your eyelids have even fully opened. 

      Checking Email.jpeg

      And now, with the increased usage of everything mobile, people are “always on” in terms of their inboxes: whether on commutes, in the bathroom (germy, but true), or in almost every social situation, they’re one micro-click away from checking their email.

      Email marketing capitalizes on habits like this in a major way. 

      At its most basic, email marketing involves acquiring the email addresses of potential customers as a way to share content with them and build business-to-customer relationships. And there’s a reason that this strategy is tried-and-true; it’s a good investment — for every dollar spent, email marketing averages an ROI of $38. Cha-ching!

      The numbers don’t lie: 66% of consumers have made a purchase online as a direct result of an email marketing message. 

      Still not convinced that you need an email marketing strategy? Consider these stats:

      • You are six times more likely to get a click-through from an email campaign than you are from a tweet. Bonus: you get more than 140 characters to do it.
      • 90% of email gets delivered to the intended recipient’s inbox, whereas only 2% of your Facebook fans see your posts in their News Feed (they’re probably watching cat videos).
      • Email is 40 times more effective at acquiring new customers than Facebook or Twitter and achieves 174% more conversions.
      • More people use email than social platforms
      • Email is a direct line of communication you have with website visitors that explicitly said they want to hear from you!
      • Some social media platforms cater to specific age groups — and not others (hello, Snapchat). Biting your nails over catering to millennials, baby boomers, or Gen Xers, respectively? Email marketing crosses age groups in terms of effectiveness. Email is the preferred means of business communications across all age groups.
      • Once you have their email address, you can continue to market to your subscribers for mere pennies (unless they unsubscribe). A budget-friendly marketing gift that keeps on giving!

      Consider a basketball analogy: Email marketing is like shooting a layup, versus a shot from half-court . . . blindfolded. One is targeted and direct — an almost guaranteed score — while the other is haphazard hit-or-miss. 

      Basketball Layup.jpeg

      Point made, yes?

      So, let’s get down to it.

      What You Need to Get Started

      If you’re a business owner, you’ve probably got a snazzy website up and running. If not, follow this guide to building a WordPress website in five minutes and then rejoin us. 

      Don’t worry. We’ll wait.

      All setup? OK, now it’s time to market your content and products to loyal followers.

      First, it’s smart to set some goals and make a plan for what you want to accomplish through your email marketing efforts. This will guide the type of messages you sent and how you target your subscribers.

      Second, you’ll need a reliable Email Service Provider (ESP). This kind of provider is different than your basic Gmail account — an ESP allows you to send messages in bulk.

      The most popular of these is probably MailChimp. Still, many ESPs offer various features — like security reports and levels of automation — so do your research and choose a service that provides the tools you want at the price your budget allows.


      Next: Building a list of subscribers.

      Successful email marketing works like visiting someone’s house — you have to be invited first. Email marketing begins when a potential or current customer gives you their permission to send them emails. 

      Just say “Nooooooo!” to buying email lists or firing off spammy messages to those who haven’t granted you their permission. You want to nurture relationships that lead to sales, not alienate and annoy potential customers. (We’ll address this more in the “Slam That Spam” section below).

      For your website, you accomplish this with an opt-in form. You’ve probably seen a handful of different versions of these on nearly every web page you visit. 

      Optin Sidebar.png
      A sidebar opt-in widget on food blog How Sweet Eats.
      Optin Popup.png
      A pop-up email subscription form on craft site Thimblepress.
      Optin Popup 2.png
      A creative pop-up subscription option from Chronicle Books.

      Just as there is with crafting your email content itself, there’s an art to creating a winning opt-in message, like incorporating appealing visuals, a persuasive description — that offers subscribers some kind of additional benefit — and a compelling subscribe button (among other things). 

      OptinMonster is a simple — and effective — way to set up lead capture forms on WordPress (and other websites and e-commerce sites) that integrate with many ESPs. Easy peasy!


      2. The Nitty Gritty

      Just as there is with crafting your email content itself, there’s an art to creating a winning opt-in message, like incorporating appealing visuals, a persuasive description — that offers subscribers some kind of additional benefit — and a compelling subscribe button (among other things). 

      OptinMonster is a simple — and effective — way to set up lead capture forms on WordPress (and other websites and e-commerce sites) that integrate with many ESPs. Easy peasy!

      Email Segmentation

      According to OptinMonster

      “Email list segmentation is the process of breaking your subscribers into smaller groups based on specific criteria so that you can send them more personalized and relevant emails.”

      Emails that are more targeted will help you get the right content to the people who will be most interested in reading it, resulting in higher click-through rates and conversions (not to mention a decrease in the number of those hitting the “unsubscribe” button or sending your mail to spam). By segmenting, you can vary the content, like sending your newsletter or promotional content to the most receptive audience.

      So, what kinds of groups can you segment subscribers into? Here are a few examples:

      • Location — Having an upcoming event or pop-up sale? Notify subscribers who are local to the area.=
      • New Subscribers — Welcome the newbies and let them know how glad you are to have them as a part of your following.
      • Items Remaining in Shopping Cart — Give a call to action to those hesitant or forgetful shoppers. Remind subscribers with yet-to-be-purchased products in their online carts to complete their check-out.
      • Preferences — Segment your emails based on certain types of emails. Some subscribers may only want to be notified about upcoming sales or discounts; others may want news of every just-launched blog post. 
      • Open Rate — Call it a “frequent-reader” perk: lavish your engaged subscribers with unique content or premiums.
      • Survey or Quiz Results — Group customers based on how they respond to your prompts for feedback.

      Online Shopper.jpeg

      Those are just a few ideas on the ways you can segment your email list (and there are tons more). 

      The goal of segmentation is personalization; each subscriber receives content relevant to them and will, therefore, interact with the content more. Picture it: fewer spam designations, more engagement, more successful email campaigns, more conversions, etc.

      This can also be accomplished with OptinMonster as it integrates with your ESP.


      Along with segmentation is sequencing, a tactic in which a series of emails are generated based on set intervals or subscriber behavior-triggered automations

      Sequencing helps you automate (less work for you) and get the right messages to your subscribers — the groups you’ve segmented — when they will be most effective. (More details here.) 

      Types of sequences may include a series of emails targeted at reactivating disengaged subscribers, encouraging them to attend a local event, or following up on a recent purchase.

      And it works; after one year of using automation, 32% of businesses reported increased revenue.

      3. Slam That Spam

      A major — repeat, major — part of your email marketing success (aka increased conversions, killer content, and a growing readership) is understanding — and avoiding — the spam folder. 

      So what is spam exactly? Well, in short, it’s unsolicited messages (meaning, no consent was given to receive them) sent in bulk. While sometimes amusing to read, spam is ultimately annoying to consumers, and no business wants their carefully crafted copy relegated to the black hole abyss of email spam holes. 


      It’s true: Consumers are deleting fewer promotional emails without looking than in years past.

      But with this, there’s good news and bad news. 

      • The good: As people are sending fewer email communications to the trash (or spam) bin, it’s a sign that perhaps email marketers are refining their craft so that email messages are more useful to consumers.
      • The bad: Spam filters are better and more aggressive than ever before, so it’s important to take care that your emails don’t lead to a negative brand association. 

      So let’s consider a few (OK, several) roadblocks that can stall you from reaching your consumers’ inboxes.

      Understand the How of Spam Filters

      An important key is understanding how the filters work in the first place. While there are many triggers, here are some things they look for:

      • Relationship with subscriber
      • Reputation of IP address and sender domain (read more on this here)
      • Quality of email subject line, teaser, and content
      • Quality and safety of included links
      • Presence or absence of images
      • Inclusion of text version of the email

      Additionally, spam filters monitor subscriber behavior to improve their filtering formulas, tracking actions like the opening of emails, time spent reading the email, enabling of images, spam flagging, folders applied to email by the subscriber, forwarding of emails, etc. 

      And because these behaviors vary from subscriber to subscriber, a unique “email spam score” is given to each email sent to every individual subscriber. Sounds complicated, but there are things you can do to significantly improve your chances that your message will arrive successfully to your subscriber.

      Spam filters are smart. Some other instant red flags: over-the-top font colors (consumers don’t like this either), font color tags that aren’t formatted correctly, misspellings, overstuffing keywords, and risky word choices (best to avoid “free,” “prize,” “promo,” “no obligation,” and “buy”). 

      In addition, be conservative with punctuation and capitalization. Aside from the resulting in red-flagging, it’s just . . . ANNOYING!!!!! 

      See? We told you.

      Lastly, don’t play dirty. Attempting to outsmart spam filters (like inserting random characters and numbers into your content or subject lines or concealing text in an image) or tricking your subscribers by starting the subject line with “Re:” or “Fwd:” to suggest an ongoing communication with you just eats away at your credibility.

      Instead, put your efforts into building a quality email list and sending out content that customers want to see pop up in their inbox.

      Build Your Own In-House Email List

      The permission-based approach is best. Make sure that the recipients of your messages have provided explicit consent to receive your communications through a sign-up or opt-in form. Encourage them to add your email to their address book.

      Resist the temptation to purchase an email list or scrape sites for addresses. This is often your message’s one-way ticket to the spam folder. Build your list ethically.

      Make Unsubscribing Easy

      No one wants a dwindling email list, but the reality is this: 50% of consumers branded a company’s email as spam because they couldn’t easily figure out how to unsubscribe to the messages. 

      Make it easy for your subscribers to part ways; it’ll save you the spam label and leave you with the most invested subscribers — plus, it’s the law!

      Don’t Send Lackluster or Irrelevant Content

      Consistency is the rule for creating content on your website. This make-it-or-break-it principle is critical for your email communications too. If your blog channels a friendly-neighbor tone, you should have an email voice to match. Keep your messaging consistent, so you don’t give your readers branding whiplash. 

      Secondly, honor your subscribers’ time. As it has been aptly said, minutes of your customers’ time are like dog years on the internet — woof. 

      Our digital diets are only programmed for rapid-fire “tastes” of virtual content, so your subscribers’ time reading your content should be well-spent. Honor their minutes by making your emails worth reading. Otherwise, it’s “Email, meet Trash Bin.”

      Also, understand that you really only have a few seconds to grab their attention in the first place. Research shows that most people have a group of “trusted advisers” from whom they will almost always open emails — secure this spot and your customers’ attention is yours. 

      Using a Reliable Email Service Provider (ESP)

      In addition to checking your domain name for blacklisting (you might also hear this referred to as a denylist), you should use a reputable ESP. Need help choosing the right provider? Check here. You could also consider getting third-party accreditation, which can help deliverability. 

      Understand the Rules

      More than just staying clear of boring or unrelated content, you need to be aware of the rules surrounding email marketing and how your content could potentially be violating established spam laws. With most — if not all — email providers, you will need to verify that you are abiding by the law.

      CAN-SPAM Act applies to “any electronic mail message the primary purpose of which is the commercial advertisement or promotion of a commercial product or service.” Simply put, all emails must comply. Each email in violation can incur a fee of upwards of $40,000! Gulp.

      Here are the must-dos and don’t-even-think-about-its for staying on the right side of the law.

      1. Don’t Deceive or Mislead

      Your “From,” “To,” “Reply-To,” routing info (the domain name and email address), and subject line must all accurately reflect the correct information, including the business the message is originating from and the content of the message. Be truthful and clear. 

      2. Identify Ad Content

      You must communicate clearly and visibly that your message is an advertisement. 

      3. Give Your Location

      In your email, you must include the physical address of your business (whether that be a street address, P.O. box, or private mailbox you’ve registered under Postal Service regulations).

      4. Tell Subscribers How to Opt-Out

      It’s not just a good idea to have an easy unsubscribe method. Letting your subscribers know, clearly and conspicuously, how to opt out of future messages is the law. You must give subscribers the choice to stop emails, and you must explain how (by using a clear, contrasting font to distinguish it on your email, by giving a return address to reply to — which should be a human reply-to address — or providing another internet-based way). 


      Additionally, make certain that your own spam filter does not block opt-requests from subscribers. Another element of the law is honoring these requests swiftly (within 10 business days) and not requiring additional demands from the subscriber, like fees, personal information, or other actions besides visiting a single page or sending a reply email. You cannot transfer or sell the former subscriber’s email address.

      5. Understand Your Personal Obligation

      Chances are that if you’re reading this, you’re working on improving (or starting) your business’s email marketing strategy. But, on the off chance that you’re merely reading this for fun (totally understandable) and you’ve hired someone else to manage your email marketing, understand that you still possess the legal responsibility to comply with the law. Even if it’s just your product promoted in the email messages, you could be held legally responsible for violations. You can read up on more details here.

      6. Keep Your Email List Updated

      It’s important to stay connected with your subscribers and keep your email list as up-to-date as possible, as email addresses change often. Hey, that young professional doesn’t want to use their “” address forever. A stale list can lead to too many hard bounces (emails rejected for permanent reasons like invalid or inoperable email addresses) and raise your spam score.

      7. Think Timing

      Sure, your subscribers might not like a lengthy email every day, but sending out a rare email every few months could hurt. When your messages do show up, your readers might not recognize the “From:” designation and send you straight to spam or delete your message quickly, damaging your stats and credibility. 

      8. Consider Size

      If your email content is too large, it could result in a soft bounce, a temporary delivery issue that signifies that your content got as far as your subscriber’s mail server but was then bounced back. Reasons for soft bounces may also include full inboxes or an offline server. The email provider you use should attempt to resend your email over a period of days, but be on the lookout for repeat bounces and remove them from your list. (Read more about bounce rates in the Metrics section below).

      9. Be Wary of Inserts

      Videos, embedded forms, and attachments aren’t smart things to include in your email messages. Forms and videos often aren’t supported for security and compatibility reasons. Plus, there’s mobile to think about (more than that later). If you have an additional PDF or worksheet you want to share, upload it to your site and provide a link in the email you send out. 

      10. Test Before You Send

      Lastly, it’s smart to use a service like to test your email for possible spam triggers.

      Not Spam.png

      And for the record, we’re web hosting experts, so talk with a legit attorney if you really want to get into the minutiae of spam law.

      We’ll Support Your Dream

      Whatever your online goals, we’ll be right there with you, making sure your site is fast, secure, and always up. Plans start at $2.59/mo.

      4. Putting Pen to (Virtual) Paper

      It’s time to decide the type of content you want to send out. A good tip is to analyze your email reports and website analytics to see what content did best — and get writing more of that. Here are some email communication best practices that will earn you more opens, more engagement, and more satisfied subscribers. 

      Be a Stickler for Good Grammar

      This isn’t seventh-grade English class, but it’s important to put in the work to make sure your content is error-free and professional. You want your subscribers to trust you and keep returning to read. Get a second pair of eyes and use an editing checklist to help you spot mistakes. Nothing turns off a subscriber more than a misplaced comma or spelling error. Can you say amatuer amateur?

      Write Like a Friend

      While you still need to be professional, it’s also important to write conversationally and not like a robot. Add personal touches that help show your personality and approachability. Also, use the word “you.” Turns out it’s pretty convincing.

      Promptly Journals.png
      The emails from Promptly Journals make you feel like a VIP, not just a subscriber.

      Learn From the Pros

      There are a lot of companies out there who are doing email marketing well. Here are a few. Learn from the best and adapt your content to adhere to winning principles and make your emails — dare we say it — fun to read! 

      Make it Visually Appealing

      If your subscribers wanted to slog through dense copy, they’d read a textbook. Remember, they’re “snacking,” so avoid clutter and make it easy for them to find what they’re looking for with text breakups, visual cues, and a clean design. 

      Invite Readers to Take Action

      Just like a good story needs a good ending, don’t leave your email with a blah finish. Give a clear call-to-action prompt that engages your subscriber to do more. I mean, that’s why you’re sending the email in the first place, right?

      Take Your Subject Line Seriously

      Subscribers decide whether your emails are worth their time and attention in 0 to 3 seconds. One, two, done. Another scary fact: 70% of emails get flagged as spam based solely on the subject line! So make it enticing and relevant. Again, learn from the pros.

      Some important things to keep in mind when writing subject lines:

      • Personalize, personalize, personalize. The more you can make your message seem tailored to each subscriber, the more they’ll keep reading — and buying.
      • Rise above clickbait. Readers will quickly ditch if promises are left unfulfilled.
      • Keep it short and sweet. 
      • Take it easy on punctuation and caps, OKAY?!?!?!
      • Offer hints at what’s inside — discount, you say? I’m enticed. Bonus points if you can make the reader feel part of an exclusive club or create a sense of urgency to act.
      • Follow an enticing sub headline with a complementary preheader. If the two play well together, you’ll have committed subscribers that anxiously await your messages.

      Subject Line.png

      5. Think Mobile

      You’re already aware that your website needs to be geared toward mobile users — the same goes for your emails. 

      But why?

      Many consumers are now reading email exclusively on mobile devices and are pretty picky about how your messages look on their devices: more than 80% of people reported that they will delete an email if it looks wonky on their phones. Yikes.


      You know the principles of optimizing your site; here’s how to optimize your messages for mobile.

      • Make Sure Your Templates Are Mobile-Ready — Regardless of which ESP you use, ensure that your message is formatted for every mobile device. Use readable fonts, a single-column layout, and touch-friendly buttons (mobile screens are small!)
      • Be Conscious of the Length of Your Subject Line — Too long, and it will get cut off on a mobile screen.
      • Resize Your Images — Make sure images and text are balanced in relation to each other.
      • Make Sure Your Links are Mobile — Verify that the pages you link to are also mobile-friendly so subscribers can successfully answer your call to action.
      • Create a Browser Version — Offer a browser version of the email so readers can open it outside of their email client.
      • Do a Practice Run — One of the best ways to assure that all content is ready to hit your subscribers’ inboxes is to send yourself a test email. Check all links, images, and subject lines in your own personal inbox. 

      6. Gauging Success

      You’ve crafted your winning email and sent it out into the interwebs — now what? How can you judge the success or failure of your email marketing campaign? What should you look for? Like any marketing effort, it’s important to analyze your results and improve any needed efforts, but what metrics are most important?


      Here is a quick-guide glossary of metrics you should keep an eye on in coordination with your personal goals.

      Bounce Rate

      As we mentioned before, bounce rate (both hard and soft) indicates the percentage of total emails that were undeliverable — permanently or temporarily — measured by the total number of bounced emails divided by the number of emails sent. Sometimes this is a server issue, sometimes it’s a spam issue. 

      Unsubscribe Rate

      This number — the rate at which people remove themselves from your email list — is a good correction tool; it can help you know which emails were causing subscribers to ditch your list and correct those issues in future communications.

      Open Rate

      The percentage of email subscribers who open a given email. But this can sometimes be misleading, as an “open” is counting as a subscriber who receives the images embedded in a particular message. But it can clue you into what subject lines are most effective, which days your emails are opened, and the average percentage of your email list responding to your messages.

      Click Rate

      The number of times links in your message are clicked on. This is important for understanding your subscribers’ level of engagement and how they are interacting with you — and acting on your invitations to buy, visit, or give feedback. 

      Action Over Time

      A timeline of engagement with your emails; this stat can assist you in planning when is the best time to send campaigns.

      Spam Score

      Not all email marketing service providers will provide you this number, but it’s worth thinking about if you can get your hands on it. Before you hit send, it can indicate the likelihood of your message getting slammed by spam filters. A Spam Complaint metric can also be used to correct past errors that caused your subscribers to designate a certain message as spam. Based on these numbers, you can adjust your content format.

      It might also be important to keep track of email client data; with this, you can see how successfully or unsuccessfully messages might be appearing on different client types. Also, encourage your subscribers to give you feedback so you can learn and improve your communications the next time around.

      Lastly, here are some tools that can help you keep track (if your service provider doesn’t already) and benchmarks that help you see how you stack up in your industry.

      The Last Word

      Take a breath. Email overload, we get it. You can always bookmark this guide and refer back to it when you’re ready to take the next step in improving your communications with subscribers. 

      And in case you scrolled all the way down here looking for the TL;DR, we’ve got you covered. Here are the key takeaways for starting your own email marketing program. 

      • Test, Test, Test — Whether it’s spot spelling mistakes or checking for possible spam triggers, test your emails before sending them. It’s an investment worth the extra few minutes.
      • Keep Your Email List Healthy — A fresh list will help you avoid a lot of issues, including spam and legal concerns, not to mention depressing analytics. Consider running a re-engagement campaign every six months or so to maintain your list.
      • Be Consistent — Not only in the type of content you share but the frequency in which you send it. Your subscribers will come to know — and trust — you and anticipate your messages.
      • Focus on Quality — Spend time on both the writing and design of your emails. These elements will not only increase your stats but help build solid relationships with subscribers. 
      • Add a Call-to-Action Button — Make that CTA easy to find and use. You want to turn those readers into customers!
      • Make It Personal — Send segmented messages to get the most relevant content to each subscriber. Personalized email subject lines are more likely to be opened.

      Now, back to that inbox.

      Ready to Create an Email Newsletter?

      Whether you need help finding a target audience, crafting the ideal social media strategy, or setting up a newsletter, we can help! Subscribe to our monthly digest so you never miss an article.

      RE: Your Feedback

      How have these email best practices gained you more subscribers or sales? What’s helped you successfully stay out of spam folders? Forward us your ideas (see what we did there?) on Twitter or join our Facebook group for site owners.

      Source link

      How To Use Enums in TypeScript

      The author selected the COVID-19 Relief Fund to receive a donation as part of the Write for DOnations program.


      In TypeScript, enums, or enumerated types, are data structures of constant length that hold a set of constant values. Each of these constant values is known as a member of the enum. Enums are useful when setting properties or values that can only be a certain number of possible values. One common example is the suit value of a single card in a deck of playing cards. Every card that is drawn will either be a club, a diamond, a heart, or a spade; there are no possible suit values beyond these four, and these possible values are not likely to change. Because of this, an enum would be an efficient and clear way to describe the possible suits of a card.

      Whereas most features of TypeScript are useful for throwing errors during compilation, enums are also useful as data structures that can hold constants for your code. TypeScript translates enums into JavaScript objects in the final code emitted by the compiler. Because of this, you can use enums to make a codebase more readable, as you can have multiple constant values grouped in the same data structure, while also making the code more type-safe than just having different const variables laying around.

      This tutorial will explain the syntax used to create enum types, the JavaScript code that the TypeScript compiler creates under the hood, how to extract the enum object type, and a use case for enums that involves bit flags in game development.


      To follow this tutorial, you will need:

      • An environment in which you can execute TypeScript programs to follow along with the examples. To set this up on your local machine, you will need the following:
      • If you do not wish to create a TypeScript environment on your local machine, you can use the official TypeScript Playground to follow along.
      • You will need sufficient knowledge of JavaScript, especially ES6+ syntax, such as destructuring, rest parameters, and imports/exports. If you need more information on these topics, reading our How To Code in JavaScript series is recommended.
      • This tutorial will reference aspects of text editors that support TypeScript and show in-line errors. This is not necessary to use TypeScript, but does take more advantage of TypeScript features. To gain the benefit of these, you can use a text editor like Visual Studio Code, which has full support for TypeScript out of the box. You can also try out these benefits in the TypeScript Playground.

      All examples shown in this tutorial were created using TypeScript version 4.2.3.

      Creating Enums in TypeScript

      In this section, you will run through an example of declaring both a numeric enum and a string enum.

      Enums in TypeScript are usually used to represent a determined number of options for a given value. This data is arranged in a set of key/value pairs. While the keys must be strings, as with JavaScript objects in general, the values for enum members are often auto-incremented numbers that mainly serve to distinguish one member from the other. Enums with only number values are called numeric enums.

      To create a numeric enum, use the enum keyword, followed by the name of the enum. Then create a curly bracket ({}) block, where you will specify the enum members inside, like this:

      enum CardinalDirection {
        North = 1,

      In this example, you are making an enum called CardinalDirection, which has a member that represents each of the cardinal directions. An enum is an appropriate choice of data structure to hold these options, since there are always only four options for values: north, south, east, and west.

      You used the number 1 as the value of the first member of your CardinalDirection enum. This assigns the number 1 to be the value of North. However, you did not assign values to the other members. This is because TypeScript automatically sets the remaining members to the value of the previous member plus one. CardinalDirection.East would have the value 2, CardinalDirection.South would have the value 3, and CardinalDirection.West would have the value 4.

      This behavior only works with numeric enums that have only number values for each member.

      You can also completely ignore setting the value of the enum members:

      enum CardinalDirection {

      In this case, TypeScript is going to set the first member to 0, and then set the other ones automatically based on that one, incrementing each by one. This will result in code identical to the following:

      enum CardinalDirection {
        North = 0,
        East = 1,
        South = 2,
        West = 3,

      The TypeScript compiler defaults to assigning numbers to enum members, but you can override this to make a string enum. These are enums that have string values for each member; these are useful when the value needs to carry a certain human-readable meaning, such as if you’ll need to read the value in a log or error message later on.

      You can declare enum members to have string values with the following code:

      enum CardinalDirection {

      Now each of the directions has a letter value that indicates which direction they are tied to.

      With the declaration syntax covered, you can now check out the underlying JavaScript to learn more about how enums behave, including the bi-directional nature of the key/value pairs.

      Bi-directional Enum Members

      Upon TypeScript compilation, enums are translated into JavaScript objects. However, there are a few features of enums that differentiate them from objects. They offer a more stable data structure for storing constant members than traditional JavaScript objects, and also offer bi-directional referencing for enum members. To show how this works, this section will show you how TypeScript compiles enums in your final code.

      Take the string enum you created in the last section:

      enum CardinalDirection {

      This becomes the following code when compiled to JavaScript using the TypeScript compiler:

      "use strict";
      var CardinalDirection;
      (function (CardinalDirection) {
          CardinalDirection["North"] = "N";
          CardinalDirection["East"] = "E";
          CardinalDirection["South"] = "S";
          CardinalDirection["West"] = "W";
      })(CardinalDirection || (CardinalDirection = {}));

      In this code, the "use strict" string starts strict mode, a more restrictive version of JavaScript. After that, TypeScript creates a variable CardinalDirection with no value. The code then contains an immediately invoked function expression (IIFE) that takes the CardinalDirection variable as an argument, while also setting its value to an empty object ({}) if it has not already been set.

      Inside the function, once CardinalDirection is set as an empty object, the code then assigns multiples properties to that object:

      "use strict";
      var CardinalDirection;
      (function (CardinalDirection) {
          CardinalDirection["North"] = "N";
          CardinalDirection["East"] = "E";
          CardinalDirection["South"] = "S";
          CardinalDirection["West"] = "W";
      })(CardinalDirection || (CardinalDirection = {}));

      Notice that each property is one member of your original enum, with the values set to the enum’s member value.

      For string enums, this is the end of the process. But next you will try the same thing with the numeric enum from the last section:

      enum CardinalDirection {
        North = 1,

      This will result in the following code, with the highlighted sections added:

      "use strict";
      var CardinalDirection;
      (function (CardinalDirection) {
          CardinalDirection[CardinalDirection["North"] = 1] = "North";
          CardinalDirection[CardinalDirection["East"] = 2] = "East";
          CardinalDirection[CardinalDirection["South"] = 3] = "South";
          CardinalDirection[CardinalDirection["West"] = 4] = "West";
      })(CardinalDirection || (CardinalDirection = {}));

      In addition to each member of the enum becoming a property of the object (CardinalDirection["North"] = 1]), the enum also creates a key for each number and assigns the string as the value. In the case of North, CardinalDirection["North"] = 1 returns the value 1, and CardinalDirection[1] = "North" assigns the value "North" to the key "1".

      This allows for a bi-directional relationship between the names of the numeric members and their values. To test this out, log the following:


      This will return the value of the "North" key:



      Next, run the following code to reverse the direction of the reference:


      The output will be:



      To illustrate the final object that represents the enum, log the entire enum to the console:


      This will show both of the sets of key/value pairs that create the bi-directionality effect:


      { "1": "North", "2": "East", "3": "South", "4": "West", "North": 1, "East": 2, "South": 3, "West": 4 }

      With an understanding of how enums work under the hood in TypeScript, you will now move on to using enums to declare types in your code.

      Using Enums in TypeScript

      In this section, you will try out the basic syntax of assigning enum members as types in your TypeScript code. This can be done in the same way that basic types are declared.

      To use your CardinalDirection enum as the type of a variable in TypeScript, you can use the enum name, as shown in the following highlighted code:

      enum CardinalDirection {
      const direction: CardinalDirection = CardinalDirection.North;

      Notice that you are setting the variable to have the enum as its type:

      const direction: CardinalDirection = CardinalDirection.North;

      You are also setting the variable value to be one of the members of the enum, in this case CardinalDirection.North. You can do this because enums are compiled to JavaScript objects, so they also have a value representation in addition to being types.

      If you pass a value that is not compatible with the enum type of your direction variable, like this:

      const direction: CardinalDirection = false;

      The TypeScript compiler is going to display the error 2322:


      Type 'false' is not assignable to type 'CardinalDirection'. (2322)

      direction can therefore only be set to a member of the CardinalDirection enum.

      You are also able to set the type of your variable to a specific enum member:

      enum CardinalDirection {
      const direction: CardinalDirection.North = CardinalDirection.North;

      In this case, the variable can only be assigned to the North member of the CardinalDirection enum.

      If the members of your enum have numeric values, you can also set the value of your variable to those numeric values. For example, given the enum:

      enum CardinalDirection {
        North = 1,

      You can set the value of a variable of type CardinalDirection to 1:

      const direction: CardinalDirection = 1;

      This is possible because 1 is the value of the North member of your CardinalDirection enum. This only works for numeric members of the enum, and it relies on the bi-directional relationship the compiled JavaScript has for numeric enum members, covered in the last section.

      Now that you have tried out declaring variable types with enum values, the next section will demonstrate a specific way of manipulating enums: extracting the underlying object type.

      In the previous sections, you found that enums are not just a type-level extension on top of JavaScript, but have real values. This also means that the enum data structure itself has a type, which you will have to take into account if you are trying to set a JavaScript object that represents an instance of the enum. To do this, you will need to extract the type of the enum object representation itself.

      Given your CardinalDirection enum:

      enum CardinalDirection {

      Try to create an object that matches your enum, like the following:

      enum CardinalDirection {
      const test1: CardinalDirection = {
        North: CardinalDirection.North,
        East: CardinalDirection.East,
        South: CardinalDirection.South,
        West: CardinalDirection.West,

      In this code, test1 is an object with type CardinalDirection, and the object value includes all the members of the enum. However, the TypeScript compiler is going to show the error 2322:


      Type '{ North: CardinalDirection; East: CardinalDirection; South: CardinalDirection; West: CardinalDirection; }' is not assignable to type 'CardinalDirection'.

      The reason for this error is that the CardinalDirection type represents a union type of all the enum members, not the type of the enum object itself. You can extract the object type by using typeof before the name of the enum. Check the highlighted code below:

      enum CardinalDirection {
      const test1: typeof CardinalDirection = {
        North: CardinalDirection.North,
        East: CardinalDirection.East,
        South: CardinalDirection.South,
        West: CardinalDirection.West,

      The TypeScript compiler will now be able to compile your code correctly.

      This section showed a specific way to widen your use of enums. Next, you will work through a use case in which enums are applicable: bit flags in game development.

      Using Bit Flags with TypeScript Enums

      In this last section of the tutorial, you’ll run through a tangible use case for enums in TypeScript: bit flags.

      Bit flags are a way to represent different boolean-like options into a single variable, by using bitwise operations. For this to work, each flag must use exactly one bit of a 32-bit number, as this is the max value allowed by JavaScript when doing bitwise operations. The max 32-bit number is 2,147,483,647, which in binary is 1111111111111111111111111111111, so you have 31 possible flags.

      Imagine you are building a game, and the player may have different skills, like SKILL_A, SKILL_B, and SKILL_C. To make sure your program knows when a player has a certain skill, you can make flags that can be turned on or off, depending on the player’s status.

      With the following pseudocode, give each skill flag a binary value:

      SKILL_A = 0000000000000000000000000000001
      SKILL_B = 0000000000000000000000000000010
      SKILL_C = 0000000000000000000000000000100

      You can now store all the current skills of the player in a single variable, by using the bitwise operator | (OR):

      playerSkills = SKILL_A | SKILL_B

      In this case, assigning a player the bit flag 0000000000000000000000000000001 and the bit flag 0000000000000000000000000000010 with the | operator will yield 0000000000000000000000000000011, which will represent the player having both skills.

      You are also able to add more skills:

      playerSkills |= SKILL_C

      This will yield 0000000000000000000000000000111 to indicate that the player has all three skills.

      You can also remove a skill using a combination of the bitwise operators & (AND) and ~ (NOT):

      playerSkills &= ~SKILL_C

      Then to check if the player has a specific skill, you use the bitwise operator & (AND):

      hasSkillC = (playerSkills & SKILL_C) == SKILL_C

      If the player does not have the SKILL_C skill, the (playerSkills & SKILL_C) part is going to evaluate to 0. Otherwise (playerSkills & SKILL_C) evaluates to the exact value of the skill you are testing, which in this case is SKILL_C (0000000000000000000000000000010). This way you can test that the evaluated value is the same as the value of the skill you are testing it against.

      As TypeScript allows you to set the value of enum members to integers, you can store those flags as an enum:

      enum PlayerSkills {
        SkillA = 0b0000000000000000000000000000001,
        SkillB = 0b0000000000000000000000000000010,
        SkillC = 0b0000000000000000000000000000100,
        SkillD = 0b0000000000000000000000000001000,

      You can use the prefix 0b to represent binary numbers directly. If you do not want to use such big binary representations, you can use the bitwise operator << (left shift):

      enum PlayerSkills {
        SkillA = 1 << 0,
        SkillB = 1 << 1,
        SkillC = 1 << 2,
        SkillD = 1 << 3,

      1 << 0 will evaluate to 0b0000000000000000000000000000001, 1 << 1 to 0b0000000000000000000000000000010, 1 << 2 to 0b0000000000000000000000000000100, and 1 << 3 to 0b0000000000000000000000000001000.

      Now you can declare your playerSkills variable like this:

      let playerSkills: PlayerSkills = PlayerSkills.SkillA | PlayerSkills.SkillB;

      Note: You must explicitly set the type of the playerSkills variable to be PlayerSkills, otherwise TypeScript will infer it to be of type number.

      To add more skills, you would use the following syntax:

      playerSkills |= PlayerSkills.SkillC;

      You can also remove a skill:

      playerSkills &= ~PlayerSkills.SkillC;

      Finally, you can check if the player has any given skill using your enum:

      const hasSkillC = (playerSkills & PlayerSkills.SkillC) === PlayerSkills.SkillC;

      While still using bit flags under the hood, this solution provides a more readable and organized way to display the data. It also makes your code more type-safe by storing the binary values as constants in an enum, and throwing errors if the playerSkills variable does not match a bit flag.


      Enums are a common data structure in most languages that provide a type system, and this is no different in TypeScript. In this tutorial, you created and used enums in TypeScript, while also going through a few more advanced scenarios, such as extracting the object type of an enum and using bit flags. With enums, you can make your code base more readable, while also organizing constants into a data dtructure rather than leaving them in the global space.

      For more tutorials on TypeScript, check out our How To Code in TypeScript series page.

      Source link