Back to Top

7 Strategies to Get Your Ad Listed in the “Top Picks” Section of Gmail’s Promotion Tab

From the time Google introduced Gmail tabs, the way marketers used email for promotions changed. Most promotional emails no longer end up in the coveted Primary tab section. Instead, promotional emails now have their own tab, one where only 19.2 percent are ever read. The best chance for promotional emails to get back on the…

The post 7 Strategies to Get Your Ad Listed in the “Top Picks” Section of Gmail’s Promotion Tab appeared first on Benchmarkemail.

Reblogged 1 year ago from www.benchmarkemail.com

11 Tips to Help You Post More Consistently

The post 11 Tips to Help You Post More Consistently appeared first on ProBlogger.

11 tips to help you post more consistently

This post is based on episode 101 of the ProBlogger podcast.

When it comes to blogging, consistency is very important. It keeps readers coming back, and ultimately determines whether or not your blog becomes one of the millions of blogs that have been abandoned over the years.

However, knowing you need to be consistent is one thing. Actually posting consistently is another. So to help keep you blogging for years to come, here are 11 tips to help you blog more consistently.

1. Don’t bite off more than you can chew

Many bloggers start out with good intentions about how often they’ll post. “I know all about this topic, so it should take any more than a few hours to write each post. That means I can publish five times a week and still have the weekends to myself.”

Then they start writing, and quickly realize that writing down their ideas in a way people can easily understand takes a lot longer than a few hours. And from there they have to decide whether to revise their schedule (and possibly eat their words) or just publish whatever they can manage in those few hours.

You’re much better off publishing consistently but less often than to promise something you simply cannot deliver. Even if your readers don’t realize you’re publishing less often than you said you would, the fact you’re not delivering on your promise will dishearten and possibly demotivate you.

Try writing a few posts and see how long they take, and work out your schedule from there.

2. Generate as many ideas as you can ahead of time

To be consistent, you need to make good use of your time. And that means knowing what you’ll be writing about before you sit in front of the keyboard. The last thing you want to be doing is trying to come up with an idea when you should be writing.

Ideally, you should have an entire list of ideas you can choose from. And to create such a list, you need to devote some time to come up with them. (Not sure how to come up with them? Here’s a post that will help.)

And keep making time for these brainstorming sessions whenever your list of ideas is getting short.

3. Block out time to create your content

You also need to devote blocks of time to actually write your posts. Don’t make the mistake of thinking you can just sit down whenever the mood hits you and thump out a post. Writing is a discipline, and to become good at it you need to do it regularly and consistently.

On some days the words will flow easily, while on others they may barely trickle onto the page. But there’s only one way to write a post, and that’s to keep showing up in front of the keyboard and pounding those keys.

And like most disciplines, the more you do it, the easier it becomes.

4. Block out some more time to polish what you’ve written

As much as you might think your first draft is perfect, chances are you can make it even better by editing it. It’s a chance to not only fix up any embarrassing, typos, but also to tighten the opening, make the transitions smoother, and even give it a better headline.

And you should always do this as a separate process rather than while you’re writing. Why? Because creating and editing use different parts of the brain, and so you need to treat them as separate processes.

And if you need some pointers on how to go about polishing your posts, we have a post than can help you with that as well.

5. Add some easy posts to the mix

Whatever niche you’ve chosen, chances are some posts will be easier for you to write than others. So make a note of the types of posts you can create quickly, and use them to give yourself a bit of breathing space when you need it.

Some posts I find relatively easy to write include:

  • reader discussions
  • polls
  • reader challenges
  • link posts
  • archive/’best of’ posts
  • interviews.

You can also invite other people to write guest posts for you.

And depending on how often you’re posting, you could create a schedule where you publish particular post types on particular days – reader discussions on Mondays, link posts on Tuesdays, reader challenges on Fridays (so they can work on them over the weekend), and so on.

6. Create an editorial calendar

Speaking of schedules, another great way to post more consistently is to create an editorial calendar.

At a basic level, it can help you plan your posts ahead of time so you can see what deadlines are coming up and when you need to have them written by. But an editorial calendar can also help you see where you can build on previous posts to create a series – a great way to hook readers into your blog.

And if you use an application such as CoSchedule (which we use for both ProBlogger and Digital Photography School), you can even schedule your posts to automatically publish at a particular time on a particular day.

Which is especially handy when you…

7. Write in batches

When you sit down at the keyboard to write, it can often take a bit of time to get into the flow. But once you’re there, the writing suddenly becomes a lot easier.

So why not take advantage of being in that’ flow state’ and keep writing? Instead of stopping once you’ve finished your post, start writing the next one. And if you’re still in the flow when you finish that one, start on the next. You’ll get a lot more done (because you’re not wasting time getting into the flow), and the quality will probably be a lot better than if you stopped and started again each time.

And when you’re done writing (and polishing) them, you can add them all to your editorial calendar in one hit.

8. Write for your audience

Writing fresh content week after week (or whatever schedule you’ve set for yourself) can be quite draining. Especially when you’re writing for complete strangers who may not even read your content, let alone enjoy it.

So don’t write it for them. Instead, write it for people you know and care about – your readers.

Some of my best posts were written on a plane while returning from a conference. Why? Because I wasn’t writing them for a stranger. I was writing them for someone I’d met at the conference, and writing about the problem they told me they were having.

So make a point of writing for your audience. And if you’re not sure who they are and what issues they’re having, it’s time to find out.

9. Create content that’s meaningful

Another tip is to remember why you created your blog in the first place.

While some people create blogs for the sole purpose of bringing in traffic (which as I mentioned last week is not a good idea), most bloggers set out to create meaningful content that can change people’s lives in some way. It’s their ‘Why?’

And your ‘Why?’ will keep you writing, because you know it’s helping someone else get through their day. Whether you’re helping them sort out their finances, fix their relationships, or even forget their troubles for five minutes, you’re making a difference to their lives.

And that’s one of the greatest feelings in the world.

10. Create content that drives you

When you’ve been blogging for a while, the process of writing fresh content, going through the polishing process and finally publishing your post might start to wear a little thin.

So why not try creating your content in a different way?

For me, podcasting was a game-changer. Not only did it help me reach a new audience who prefer listening to reading, it also brought a lot of energy to my content creation.

And with Facebook Live and YouTube, you can now add video to the mix.

So if your energy is starting to wane, it may be time to try something new.

11. Be spontaneous

While I’ve talked a lot about planning and scheduling in this post, sometimes it’s worth being a little spontaneous.

Sometimes you come across a piece of news that’s practically begging to have a post written about it. It’s as if you’ve been given a gift.

When that happens, I suggest you start writing straight away and publish quickly before its news value disappears (and before your enthusiasm wanes). Yes, you still need to polish what you’ve written, but because you were so enthusiastic it probably needs less work than you’d expect.

(Whether you publish it as a ‘one-off’ event or adjust your editorial calendar to accommodate it is up to you.)

So while planning will certainly help you more consistently in the long run, don’t be afraid to change those plans occasionally.

 

So there you have it: 11 tips to help you post more consistently. Are there any that I’ve missed? Let us know in the comments.

 

Photo by Jason Jarrach on Unsplash

The post 11 Tips to Help You Post More Consistently appeared first on ProBlogger.

     

Reblogged 1 year ago from feedproxy.google.com

Google Ads mobile app adds custom and performance insights notifications

The updates can help advertisers keep tabs on the metrics that are important to them and notify them of significant performance changes.

Please visit Search Engine Land for the full article.

Reblogged 1 year ago from feeds.searchengineland.com

Microsoft Bing updates search results interface to make it more visually immersive

Microsoft Bing updates recipe results, similar looking items, expandable carousels, infographic panels and local answers design.

Please visit Search Engine Land for the full article.

Reblogged 1 year ago from feeds.searchengineland.com

Google My Business report shows how people found your business

You can now see device and platform breakdown in your Google My Business performance reports.

Please visit Search Engine Land for the full article.

Reblogged 1 year ago from feeds.searchengineland.com

Google won’t build alternate IDs, doubles down on FLoC; Thursday’s daily brief

Plus, how to get your speaking pitches noticed

Please visit Search Engine Land for the full article.

Reblogged 1 year ago from feeds.searchengineland.com

15 Strategies To Get YouTube Subscribers

In the SaaS industry, the most successful companies prioritize the retention of their existing customers over the acquisition of new customers. Why? Because SaaS companies charge a monthly subscription, so in order to turn a profit, they need their customers paying them for many months in a row. If they can’t retain their customers for X amount of months, they’ll ultimately lose money by acquiring them.

In content marketing, the same principle applies. Retaining your audience’s attention positively impacts your brand a lot more than merely acquiring attention.

When an audience engages with your content for long periods of time on a consistent basis, they can easily turn into a loyal tribe that’s passionate about your work and recommends your brand to all their friends. In other words, staying laser-focused on retaining attention is actually the best strategy for acquiring new attention because your current customers are providing so much word-of-mouth marketing — it’s like a flywheel.

On YouTube, you retain attention by attracting subscribers to your channel. Subscribers are your most loyal fans and made a public commitment to your brand, content, and values. They’re also most likely to be fervent brand evangelists.

In regard to benefiting your YouTube channel, subscribers are crucial because YouTube will send them notifications about your new videos and feature your videos on their homepage. This means they’ll see your videos more frequently, which will help you generate more engagement.

Subscribers also watch twice as much video as non-subscribers, so the more subscribers you have, the more watch time your videos will accumulate, and the more likely YouTube will rank them higher on search and feature them in the related section.

Additionally, YouTube keeps track of the number of viewers who subscribe to your channel right after watching one of your videos. So if one of your videos generates a lot of new subscribers, they’ll reward it with higher rankings and more features in the related section.

To help you grow your YouTube subscription, we’ve fleshed out these strategies that will help you retain attention on the video platform — and not just acquire it.

1. Craft amazing content.

Today, we work in an industry where a lot of people prioritize gaming the system over crafting the best content possible. Fortunately, in regard to their algorithm, YouTube has caught on to this hollow tactic. Their algorithm rewards engagement instead of using only vanity metrics like views and clicks, so creators are incentivized to produce videos that their audience actually enjoys watching.

To craft the most engaging videos for your YouTube channel, consider measuring your videos’ performance against engagement metrics, like watch time, average watch percentage, average view duration, audience retention, and average session duration. Then, analyze this data to figure out which topics and videos generate the most engagement. Once you pinpoint these videos, you can solely focus on creating the content that viewers are most likely to engage with, helping you rake in more subscribers.

2. Use playlists to increase engagement.

Placing your videos in playlists is an extremely effective way to organize your videos in a digestible fashion. They help your viewers easily consume videos about their favorite topics and prompts them to keep watching your content.

One way to get your viewers to watch the majority of your playlists is by starting your playlists with the videos that have the highest audience retention rate and ending them with the videos that have the lowest audience retention rate.

Even better, you could create a binge-able series or show and place entire seasons of it in a playlist. And just like your favorite Netflix show, your playlists can entice your viewers to watch entire seasons of your series, subscribe to your channel, and get excited for your show’s next season.

3. Add a subscription CTA to the end of your videos.

It seems obvious, but adding a subscription CTA to the end of your videos is one of the best ways to generate more YouTube subscribers. After your viewers watch your entire video, they’ll determine if they want to keep watching more of your videos, so to maximize your subscriber growth using CTAs, consider keeping them at the end.

Additionally, if you want more subscribers, just ask. At the end of your video when you include a CTA, ask your viewers to subscribe. This reminds them that you have more exciting content they’ll want to watch.

4. Optimize your videos.

To attract subscribers to your YouTube channel, you first need to be able to get found on YouTube. To start ranking, consider optimizing your videos and channel for popular search queries by placing relevant keywords in your videos’ titles, tags, descriptions, SRT files (which are transcriptions), video files, and thumbnail files.

You should also check out the most popular queries guiding viewers to your videos, which you can find on YouTube’s Search Report. If these queries are slightly different than your video’s topic, consider updating your video to fill these content gaps and adding these keywords to your metadata. If there’s a stark difference between your topics and the queries guiding viewers to your videos, consider making brand new videos about these popular queries.

5. Create beautiful thumbnails.

Another factor that can affect your search ranking on YouTube, and in turn, your subscriber growth are your videos’ thumbnails. Since a video’s click-through rate is one of the most important ranking factors in YouTube’s search algorithm, especially during its first hour on the platform, an eye-catching thumbnail can make a huge difference in ranking number one for a query and not ranking at all.

If your video has an ordinary or sub-par thumbnail, though, it won’t persuade anyone to click through, prompting YouTube to deem the video irrelevant and decide not to rank it in their search results or distribute it through the “Recommended Videos” feed.

To create a striking thumbnail, consider including a talking head. People are naturally drawn to human faces because it’s an ingrained survival mechanism to help us quickly gauge someone’s emotions and determine if they’re a friend or foe. Also, consider contrasting the colors of your thumbnail’s foreground and background to really make it pop.

6. Interact with your audience.

One of the main best practices to retain and acquire new YouTube subscribers is to interact with your audience. You should reply to every comment if you can, even if it’s just liking it. When a viewer watches your videos and scrolls to see your content, they’ll be excited to see that you engage with your audience and have created a community. In fact, it might make them want to join your community and get them to subscribe.

Interacting with your audience will also generate word of mouth and engagement. The more that your audience engages with you, the higher you’ll rank, and the more people will find your content.

7. Promote your videos in your other content.

Whether you have a blog or other social media platforms, it’s important to promote your YouTube videos in your other content. When you post a video, you should also promote it on social media to get your audience to watch it.

Additionally, if you have a blog, you can embed your YouTube videos as complementary content. This will help you increase your views, and tap into the audience you’ve already created. If someone follows you on Instagram, or reads your blog, they’re probably interested in what you have to say. Don’t be afraid to cross-promote on other channels to get more subscribers.

8. Release videos consistently.

One important factor in getting YouTube subscribers that isn’t discussed as much in the influencer industry is trust. When you’re creating content, your audience needs to trust you. They have to trust that you’re going to release quality content, consistently. Otherwise, why would they subscribe?

To build this trust, it’s important that your audience can rely on you. You should release your videos on a consistent basis. This doesn’t mean you need to value quantity over quality. Whatever your publishing schedule is doesn’t matter as much as being consistent with it. Whether you post once a week or twice a month.

9. Be creative.

As we mentioned above, when you’re creating YouTube videos, it’s important to optimize your content and keep in mind what your audience is searching for. However, that doesn’t mean all your videos need to be tied to a keyword.

Sometimes it’s okay to stray and just produce creative content that’s not necessarily supported by keywords. This content can be trendy, or rely on thought leaders. Regardless, don’t be afraid to use content that strays from the organic search strategy. This will help create buzz and hopefully convert viewers into subscribers.

10. Partner with other channels.

When the influencer industry began, brands recognized that they could leverage other people’s audience to market or promote their products. The same principles apply in YouTube. If you partner with other YouTube creators, you can use each other’s audience to promote your channel.

If you do this, make sure you choose channels that align with your audience’s interests, wants, and needs. It might not make sense, for instance, for a B2B company to parter with a B2C company. Your audiences should be similar enough that someone who subscribes to their channel might also be interested in your channel.

11. Make an engaging channel trailer.

After watching an engaging or interesting YouTube video, a viewer might click on your profile to see what your channel is about. In this short time period, you need to close the sale. One of the first things viewers see when they click on a channel is the trailer video. That’s why it’s important to create an engaging, fun channel trailer.

With this trailer, you can get a viewer to go from a casual viewer to a subscriber. In your trailer video, make sure you give your elevator pitch. Why should someone subscribe to your channel? What kind of content will they see?

12. Run YouTube advertising campaigns.

An oldie but a goodie. To promote your YouTube channel, run paid advertising campaigns. You can run banner or display ads promoting your channel across platforms. This will help you get the word out about your channel, get more views, rank higher, and hopefully get a few subscribers as well.

13. Produce subscriber only content.

You know how marketers create lead magnets to entice readers or viewers to download a piece of content? To get more YouTube subscribers, apply the same principle here. You can create specific lead magnetics to get people to subscribe.

For instance, perhaps every subscriber gets a free ebook. Or maybe it’s a template. Whatever it is, think of what will be helpful to your audience and might get them to subscribe to get it.

14. Pick a niche.

As with all content you produce, your YouTube videos should be highly targeted toward your audience. Pick a niche and a theme, and stick with it. While you might have a broad theme, you can create smaller subtopics and create several videos for those topics. Think of it like the pillar/cluster model for blog writing. While your blog will focus on one niche, like marketing, there are several pillar topics that you cover and cluster topics as well.

Using this model will help you create valuable content consistently. It’ll be easier to come up with targeted, personalized video ideas for your audience if you know what they want to see.

15. Know your audience.

Again, this is a classic marketing tip. On any channel you’re creating content on, you need to know your audience. For YouTube, think about whether your audience wants to watch long or short videos. This might vary by industry, so do some research to see what type of YouTube videos and what format your audience is looking for.

How to See Your Subscribers on YouTube

To see your YouTube subscribers, all you need to do is log on to your account, click your profile photo in the top right, and click “Your Channel.” From there, you should be able to see how many subscribers you have underneath your channel name.

It’s important to continue tracking this number as you’re trying to grow your YouTube channel. Now, let’s get into the discussion about buying YouTube subscribers and why you should never do it.

Buying YouTube Subscribers

First and foremost, let’s start with the fact that you should never buy YouTube subscribers. To start, it’s against the Terms of Service with YouTube, so your account will likely be suspended or terminated if you’re caught.

Second, buying YouTube subscribers will ultimately end up hurting your channel regardless of if you’re caught or not. Bought subscribers aren’t going to engage with your content, and after maybe one video, they won’t watch it either. Having a million subscribers doesn’t matter if only 50 people are actually watching the videos and engaging with your content. Those types of numbers are major red flags both for YouTube, but also for your average viewer.

Similar to the best SaaS companies, the top YouTube channels focus on building a subscriber base that can’t get enough of their videos and watches them on a consistent basis. Retaining attention has always been imperative to successful content marketing. Now, it’s time we actually prioritize it over acquiring as many darting eyeballs as possible.

Reblogged 1 year ago from blog.hubspot.com

The State Of Mobile And Why Mobile Web Testing Matters

Things have changed quite a bit over the last decade when we just started exploring what we could do on a tiny, shiny mobile screen. These days, with mobile traffic accounting for over 50% of web traffic, it’s fair to assume that the very first encounter of your prospect customers with your brand will happen on a mobile device.

Depending on the nature of your product, the share of your mobile traffic will vary significantly, but you will certainly have some mobile traffic — and being prepared for it can make or break the deal. This requires your website or application to be heavily optimized for mobile. This optimization is quite complex in nature though. Obviously, our experiences will be responsive — and we’ve learned how to do so well over the years — but it also has to be accessible and fast.

This goes way beyond basic optimizations such as color contrast and server response times. In the fragmented mobile landscape, our experiences have to be adjusted for low data mode, low memory, battery and CPU, reduced motion, dark and light mode and so many other conditions.

Leaving these conditions out of the equation means abandoning prospect customers for good, and so we seek compromises to deliver a great experience within tight deadlines. And to ensure the quality of a product, we always need to test — on a number of devices, and in a number of conditions.

State Of Mobile 2021

While many of us, designers and developers, are likely to have a relatively new mobile phone in our pockets, a vast majority of our customers isn’t quite like us. That might come a little bit unexpected. After all, when we look at our analytics, we will hardly find any customers browsing our sites or apps with a mid-range device on a flaky 3G connection.

The gotcha here is that, if your mobile experience isn’t optimized for various devices and network conditions, these customers will never appear in your analytics — just because your website or app will be barely usable on their devices, and so they are unlikely to return.

In the US and the UK, Comscore’s Global State of Mobile 2020 report discovered in August 2020, that mobile usage accounted to 79% and 81% of total digital minutes respectively. Also, there was a 65% increase in video consumption on mobile devices in 2020. While a vast majority of the time is spent in just a few mobile apps, social media platforms provide a gateway to the web and your services — especially in education.

On the other hand, while devices do get better over time in terms of their capabilities and battery life, older devices don’t really get abandoned or disappear into the void. It’s not uncommon to see customers using devices that are 5-6 years old as these devices often get passed through the generations, serving as slightly older but “good enough” devices for simple, day-to-day tasks. In fact, an average consumer upgrades their phone every 2 years, and in the US phone replacement cycle is 33 months.

Globally in 2020, 84.8% of all shipped mobile phones are Android devices, according to the International Data Corporation (IDC). Average bestselling phones around the world cost just under $200. A representative device, then, is an Android device that is at least 24 months old, costing $200 or less, running on slow 3G, 400ms RTT and 400kbps transfer, just to be slightly more pessimistic.

This might be very different for your company, of course, but that’s a close enough approximation of a majority of customers out there. In fact, it might be a good idea to look into current Amazon Best Sellers for your target market.

Mobile is a spectrum, and a quite entrenched one. While the mobile landscape is very fragmented already, the gap between the experience on various devices will be widening much further with the growing adoption of 5G.

According to Ericsson Mobility Visualizer, we should be expecting a 15× increase in mobile 5G subscribers, from 212 million in 2020, to 3.3 billion by 2026.

If you’d like to dive deeper into the performance of Android and iOS devices, you can check Geekbench Android Benchmarks for Android smartphones and tablets, and iOS Benchmarks for iPhones and iPads.

It goes without saying that testing thoroughly on a variety of devices — rather just on a shiny new Android or iOS device — is critical for understanding and improving the experience of your prospect customers, and how well your website or app performs on a large scale.

Making A Case For Business

While it might sound valuable to test on mobile devices, it might not be convincing enough to drive the management and entire organization towards mobile testing. However, there are quite a few high-profile case studies exploring the impact of mobile optimization on key business metrics.

WPO stats collects literally hundreds of them — case studies and experiments demonstrating the impact of web performance optimization (WPO) across verticals and goals.

Driving Business Metrics

One of the famous examples is Flipkart, India’s largest e-commerce website. For a while, Flipkart adopted an app-only strategy and temporarily shut down its mobile website altogether. The company found it more and more difficult to provide a user experience that was as fast and engaging as that of their mobile app.

A few years ago, they’ve decided to unify their web presence and a native app into a mobile-optimized progressive web app, resulting in a 70% increase in conversion rate. They discovered that customers were spending three times more time on the mobile website, and the re-engagement rate increased by 40%.

Improving Search Engine Visibility

It’s not big news that search engines have been considering mobile friendliness as a part of search engine ranking. With Core Web Vitals, Google has been pushing the experience factors on mobile further to the forefront.

In his article on Core Web Vitals and SEO, Simon Hearne discovered that Google’s index update on 31st of May 2021 will result in a positive ranking signal for page experience in mobile search only, for groups of similar URLs, which meet all three Core Web Vital targets. The impact of the signal is expected to be small, similar to HTTPS ranking boost.

One thing is certain though: your websites will rank better if they are better optimized for mobile, both in terms of speed and mobile-friendliness — it goes for accessibility as well.

Improving Accessibility

Building accessible pages and applications isn’t easy. The challenges start with tiny hit targets, poor contrast and small font size, but it quickly gets much more complicated when we deal with complex single-page-applications. To ensure that we cater well for our customers in various situations — with permanent, temporary and situational disabilities — we need to test for accessibility.

That means considering keyboard navigation, how navigation landmarks are properly assigned, how updates are announced by a screen reader, focus traps, and whether we avoid any inaccessible libraries or third-party scripts. And then, for every component we are building, we need to ensure that we keep them accessible over time.

It shouldn’t be surprising that if a website isn’t accessible to a customer, they are unlikely to access your product either. The earlier you invest in accessibility testing, the more you’ll save down the road on expensive consultancy, expensive third-party services, or expensive lawyers.

Mobile Web Testing

So, with all the challenges in the mobile space, how, then, do we test on mobile? Fortunately, there is no shortage of mobile testing tools out there. However, most times, when performing mobile testing, the focus is mostly on consistency and functionality but for a more thorough mobile test, we need to go a layer deeper into some not-so-obvious specifics of testing.

Screen sizes

Screen sizes are one of the many things that are always changing in the realm of mobile devices. Year after year new screen sizes and pixel densities appear with new device releases. This poses a problem in testing websites and apps on these devices, making debugging more difficult and time-consuming.

OS Version fragmentation

With iOS having a high adoption rate on its latest OS releases (a rate of 57% on its latest iOS 14), and the plethora of versions still being used by Android devices going as far back as Ice Cream Sandwich, one must make sure to account to this fragmentation when doing mobile testing.

Browser fragmentation

With Chrome and Safari having a global usage of 62.63% and 24.55% on mobile respectively, one might be tempted to focus on just these browsers when performing mobile tests. However, depending on the region of the world, you are more likely to test in other, less-known browsers, or proxy browsers, such as Opera Mini. Even though their percentage usage might be small, it might run into hundreds of thousands of usage globally.

Performing Mobile Web Testing

To perform mobile web testing, one option is to set up a device lab, and run tests locally. In times of remote work, it’s quite challenging as you usually need a number of devices at your disposal. Acquiring these devices doesn’t have to be expensive, and experiencing the loading on your own is extremely valuable.

However, if you want to check how consistent the experience is, or conduct automated tests, it’s probably not going to be enough.

In such cases, a good starting point is Responsively, a free open-source tool with mirrored interactions, customizable layout, 30+ built-in device profiles, hot reloading and screenshot tools.

There are also other helpful tools that you may want to look into:

  • LT Browser
    LT Browser is a free-to-use desktop application that helps you build well-performing, responsive websites or web apps. It has 50+ built-in device resolutions — for mobile, tablet and desktop. You can check the mobile view of your website in a side by side comparison view with mirrored interactions and touch support.

Once you have downloaded the browser and registered, you can build, test, and debug your website, as well as take screenshots and videos of bugs, assign them to specific devices, run a performance profiling and observe multiple devices side by side. By default, a free version provides 30 mins per day.

If you need something slightly more advanced, LambdaTest allows you to run a cross-browser test on 2000+ devices on different operating systems with which you can even perform both manual and automated browser testing. (Full disclosure and reminder: LambdaTest is a friendly sponsor of this article.)

  • Sizzy
    This tool supports sync scrolling, clicking and navigation across devices, as well as takes screenshots of all devices at once, with and without a device frame. Plus, it includes a Universal Inspect Element to inspect all devices at once.
  • Blisk
    Another little helpful tool that supports over 50 devices out of the box, along with sync scrolling. You can test touch support and preview devices side-by-side, working with the same piece of code across all opened devices. Hot-reloading is supported as well, as well as video recording and screenshots.
  • Polypane
    The tool also allows you to preview your website on 27 devices, along with sync scrolling, clicks, touch, keyboard and hovers. It provides a comprehensive support of media queries (e.g. prefers-reduced-data) and a suite of debugging tools like accessibility review, CSS layout and link testing.
  • BrowserStack
    The service provides an option to automate testing as well as testing for low battery, abrupt power off, and interruptions such as calls or SMS.
  • Also, if you wish to stick with device labs to automate testing then you can set up an in-house Selenium Grid with open-source solutions i.e. Zalenium, Aerokube.

Conclusion

In this article, we have looked into the state of mobile in 2021. We’ve seen the growing usage of mobile devices as the primary means to access the web, and we’ve looked into some challenges related to that. We’ve also looked into mobile testing, and how some tools can help us find and fix bugs on mobile.

Keep in mind that your website is the face of your business and more and more users are going to access it via their mobile phones. It’s important to make sure that your users can access the services you provide on your website and have an accessible and fast experience on their devices as they do on the desktop version. This will ensure that the benefits of brand visibility get the attention they deserve.

Reblogged 1 year ago from smashingmagazine.com

Creating An Outside Focus And Click Handler React Component

Oftentimes we need to detect when a click has happened outside of an element or when the focus has shifted outside of it. Some of the evident examples for this use case are fly-out menus, dropdowns, tooltips and popovers. Let’s start the process of making this detection functionality.

The DOM Way To Detect Outside Click

If you were asked to write code to detect if a click happened inside a DOM node or outside of it, what would you do? Chances are you’d use the Node.contains DOM API. Here’s how MDN explains it:

The Node.contains() method returns a Boolean value indicating whether a node is a descendant of a given node, i.e. the node itself, one of its direct children (childNodes), one of the children’s direct children, and so on.

Let’s quickly test it out. Let’s make an element we want to detect outside click for. I’ve conveniently given it a click-text class.

<section>
  <div class="click-text">
    click inside and outside me
  </div>
</section>
const concernedElement = document.querySelector(".click-text");

document.addEventListener("mousedown", (event) => {
  if (concernedElement.contains(event.target)) {
    console.log("Clicked Inside");
  } else {
    console.log("Clicked Outside / Elsewhere");
  }
});

We did the following things:

  1. Selected the HTML element with the class click-text.
  2. Put a mouse down event listener on document and set an event handler callback function.
  3. In the callback function, we are checking if our concerned element — for which we have to detect outside click — contains the element (including itself) which triggered the mousedown event (event.target).

If the element which triggered the mouse down event is either our concerned element or any element which is inside the concerned element, it means we have clicked inside our concerned element.

Let’s click inside and outside of the element in the Codesandbox below, and check the console.

Wrapping DOM Hierarchy Based Detection Logic In A React Component

Great! So far we saw how to use DOM’s Node.contains API to detect click outside of an element. We can wrap that logic in a React component. We could name our new React component OutsideClickHandler. Our OutsideClickHandler component will work like this:

<OutsideClickHandler
  onOutsideClick={() => {
    console.log("I am called whenever click happens outside of 'AnyOtherReactComponent' component")
  }}
>
  <AnyOtherReactComponent />
</OutsideClickHandler>

OutsideClickHandler takes in two props:

  1. children
    It could be any valid React children. In the example above we are passing AnyOtherReactComponent component as OutsideClickHandler’s child.

  2. onOutsideClick
    This function will be called if a click happens anywhere outside of AnyOtherReactComponent component.

Sounds good so far? Let’s actually start building our OutsideClickHandler component.

import React from 'react';

class OutsideClickHandler extends React.Component {
  render() {
    return this.props.children;
  }
}

Just a basic React component. So far, we are not doing much with it. We’re just returning the children as they are passed to our OutsideClickHandler component. Let’s wrap the children with a div element and attach a React ref to it.

import React, { createRef } from 'react';

class OutsideClickHandler extends React.Component {
  wrapperRef = createRef();

  render() {    
    return (
      <div ref={this.wrapperRef}>
        {this.props.children}
      </div>
    )
  }  
}

We’ll use this ref to get access to the DOM node object associated with the div element. Using that, we’ll recreate the outside detection logic we made above.

Let’s attach mousedown event on document inside componentDidMount React life cycle method, and clean up that event inside componentWillUnmount React lifecycle method.

class OutsideClickHandler extends React.Component {
  componentDidMount() {
    document
      .addEventListener('mousedown', this.handleClickOutside);
  }

  componentWillUnmount(){
    document
      .removeEventListener('mousedown', this.handleClickOutside);
  }

  handleClickOutside = (event) => {
    // Here, we'll write the same outside click
    // detection logic as we used before.
  }
}

Now, let’s write the detection code inside handleClickOutside handler function.

class OutsideClickHandler extends React.Component {
  componentDidMount() {
    document
      .addEventListener('mousedown', this.handleClickOutside);
  }

  componentWillUnmount(){
    document
      .removeEventListener('mousedown', this.handleClickOutside);
  }

  handleClickOutside = (event) => {
    if (
      this.wrapperRef.current &&
      !this.wrapperRef.current.contains(event.target)
    ) {
      this.props.onOutsideClick();
    }
  }
}

The logic inside handleClickOutside method says the following:

If the DOM node that was clicked (event.target) was neither our container div (this.wrapperRef.current) nor was it any node inside of it (!this.wrapperRef.current.contains(event.target)), we call the onOutsideClick prop.

This should work in the same way as the outside click detection had worked before. Let’s try clicking outside of the grey text element in the codesandbox below, and observe the console:

The Problem With DOM Hierarchy Based Outside Click Detection Logic

But there’s one problem. Our React component doesn’t work if any of its children are rendered in a React portal.

But what are React portals?

“Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.”

React docs for portals

In the image above, you can see that though Tooltip React component is a child of Container React component, if we inspect the DOM we find that Tooltip DOM node actually resides in a completely separate DOM structure i.e. it’s not inside the Container DOM node.

The problem is that in our outside detection logic so far, we are assuming that the children of OutsideClickHandler will be its direct descendants in the DOM tree. Which is not the case for React portals. If children of our component render in a React portal — which is to say they render in a separate DOM node which is outside the hierarchy of our container div in which our OutsideClickHandler component renders its children — then the Node.contains logic fails.

How would it fail though? If you’d try to click on the children of our OutsideClickHandler component — which renders in a separate DOM node using React portals — our component will register an outside click, which it shouldn’t. See for yourself:

Using Node.contains to detect outside click of React component gives wrong result for children rendered in a React portal. (Large preview)

Try it out:

Even though the popover that opens on clicking the button, is a child of OutsideClickHandler component, it fails to detect that it isn’t outside of it, and closes it down when it’s clicked.

Using Class Instance Property And Event Delegation To Detect Outside Click

So what could be the solution? We surely can’t rely on DOM to tell us if the click is happening outside anywhere. We’ll have to do something with JavaScript by rewriting out OutsideClickHandler implementation.

Let’s start with a blank slate. So at this moment OutsideClickHandler is an empty React class.

The crux of correctly detecting outside click is:

  1. To not rely on DOM structure.
  2. To store the ‘clicked’ state somewhere in the JavaScript code.

For this event delegation will come to our aid. Let’s take an example of the same button and popover example we saw above in the GIF above.

We have two children of our OutsideClickHandler function. A button and a popover — which gets rendered in a portal outside of the DOM hierarchy of OutsideClickHandler, on button click, like so:

When either of our children are clicked we set a variable clickCaptured to true. If anything outside of them is clicked, the value of clickCaptured will remain false.

We will store clickCaptured’s value in:

  1. A class instance property, if you are using a class react component.
  2. A ref, if you are using a functional React component.

We aren’t using React state to store clickCaptured’s value because we aren’t rendering anything based off of this clickCaptured data. The purpose of clickCaptured is ephemeral and ends as soon as we’ve detected if the click has happened inside or outside.

Let’s seee in the image below the logic for setting clickCaptured:

Whenever a click happens anywhere, it bubbles up in React by default. It’ll reach to the document eventually.

When the click reaches document, there are two things that might have happened:

  1. clickCaptured will be true, if children where clicked.
  2. clickCaptured will be false, if anywhere outside of them was clicked.

In the document’s event listener we will do two things now:

  1. If clickCaptured is true, we fire an outside click handler that the user of OutsideClickHandler might have given us through a prop.
  2. We reset clickCaptured to false, so that we are ready for another click detection.

Let’s translate this into code.

import React from 'react'

class OutsideClickHandler extends React.Component {
  clickCaptured = false;

  render() {
    if ( typeof this.props.children === 'function' ) {
      return this.props.children(this.getProps())
    }

    return this.renderComponent()
  }
}

We have the following things:

  1. set initial value of clickCaptured instance property to false.
  2. In the render method, we check if children prop is a function. If it is, we call it and pass it all the props we want to give it by calling getProps class method. We haven’t implemented getProps just yet.
  3. If the children prop is not a function, we call renderComponent method. Let’s implement this method now.
class OutsideClickHandler extends React.Component {
  renderComponent() {
    return React.createElement(
      this.props.component || 'span',
      this.getProps(),
      this.props.children
    )
  }
}

Since we aren’t using JSX, we are directly using React’s createElement API to wrap our children in either this.props.component or a span. this.props.component can be a React component or any of the HTML element’s tag name like ‘div’, ‘section’, etc. We pass all the props that we want to pass to our newly created element by calling getProps class method as the second argument.

Let’s write the getProps method now:

class OutsideClickHandler extends React.Component {
  getProps() {
    return {
      onMouseDown: this.innerClick,
      onTouchStart: this.innerClick
    };
  }
}

Our newly created React element, will have the following props passed down to it: onMouseDown and onTouchStart for touch devices. Both of their values is the innerClick class method.

class OutsideClickHandler extends React.Component {
  innerClick = () => {
    this.clickCaptured = true;
  }
}

If our new React component or anything inside of it — which could be a React portal — is clicked, we set the clickCaptured class instance property to true. Now, let’s add the mousedown and touchstart events to the document, so that we can capture the event that is bubbling up from below.

class OutsideClickHandler extends React.Component {
  componentDidMount(){
    document.addEventListener('mousedown', this.documentClick);
    document.addEventListener('touchstart', this.documentClick);
  }

  componentWillUnmount(){
    document.removeEventListener('mousedown', this.documentClick);
    document.removeEventListener('touchstart', this.documentClick);
  }

  documentClick = (event) => {
    if (!this.clickCaptured && this.props.onClickOutside) {
      this.props.onClickOutside(event);
    }
    this.clickCaptured = false;
  };
}

In the document mousedown and touchstart event handlers, we are checking if clickCaptured is falsy.

  1. clickCaptured would only be true if children of our React component would have been clicked.
  2. If anything else would have been clicked clickCaptured would be false, and we’d know that outside click has happened.

If clickCaptured is falsy, we’ll call the onClickOutside method passed down in a prop to our OutsideClickHandler component.

That’s it! Let’s confirm that if we click inside the popover it doesn’t get closed now, as it was before:

Using event delegation logic correctly detects outside click, even if children are rendered in a React portal. (Large preview)

Let’s try it out:

Wonderful!

Outside Focus Detection

Now let’s take a step further. Let’s also add functionality to detect when focus has shifted outside of a React component. It’s going to be very similar implementation as we’ve done with click detection. Let’s write the code.

class OutsideClickHandler extends React.Component {
  focusCaptured = false

  innerFocus = () => {
    this.focusCaptured = true;
  }

componentDidMount(){
    document.addEventListener('mousedown', this.documentClick);
    document.addEventListener('touchstart', this.documentClick);
    document.addEventListener('focusin', this.documentFocus);
  }

componentWillUnmount(){
    document.removeEventListener('mousedown', this.documentClick);
    document.removeEventListener('touchstart', this.documentClick);
    document.removeEventListener('focusin', this.documentFocus);
  }

documentFocus = (event) => {
    if (!this.focusCaptured && this.props.onFocusOutside) {
      this.props.onFocusOutside(event);
    }
    this.focusCaptured = false;
  };

getProps() { return { onMouseDown: this.innerClick, onTouchStart: this.innerClick, onFocus: this.innerFocus }; }

Everything’s added mostly in the same fashion, except for one thing. You might have noticed that though we are adding an onFocus react event handler on our children, we are setting a focusin event listener to our document. Why not a focus event you say? Because, 🥁🥁🥁, Starting from v17, React now maps onFocus React event to focusin native event internally.

In case you are using v16 or before, instead of adding a focusin event handler to the document, you’ll have to add a focus event in capture phase instead. So that’ll be:

document.addEventListener('focus', this.documentFocus, true);

Why in capture phase you might ask? Because as weird as it is, focus event doesn’t bubble up.

Since I’m using v17 in all my examples, I’m going to go ahead use the former. Let’s see what we have here:

React Foco component correctly detecting outside click and focus by using event delegation detection logic. (Large preview)

Let’s try it out ourselves, try clicking inside and outside of the pink background. Also use tab and shift + tab keys ( in chrome, firefox, edge ) or Opt/Alt + Tab and Opt/Alt + Shift + Tab ( in Safari ) to toggle focussing between inner and outer button and see how focus status changes.

Conclusion

In this article, we learned that the most straightforward way to detect a click outside of a DOM node in JavaScript is by using Node.contains DOM API. I explained the importance of knowing why using the same method to detect clicks outside of a React component doesn’t work when the React component has children which render in a React portal. Also, now you know how to use a class instance property alongside an event delegation to correctly detect whether a click happened outside of a React component, as well as how to extend the same detection technique to outside focus detection of a React component with the focusin event caveat.

Related Resources

  1. React Foco Github Repository
  2. mdn documentation for Node.contains DOM api
  3. React docs for portals
  4. React createElement API
  5. React Github codebase Pull Request for mapping onFocus and onBlur methods to internally use focusin and focusout native events.
  6. Delegating Focus and Blur events
Reblogged 1 year ago from smashingmagazine.com

Google adds familiar face as Ads Product Liaison; Wednesday’s daily brief

Plus, advice from European PPC pros on how to navigate Maryland’s new ads tax

Please visit Search Engine Land for the full article.

Reblogged 1 year ago from feeds.searchengineland.com