I recently read a medium post where the author claimed that using async-await is better than using promises. While this might hold good in general cases, I think that generalisation was too broad and doesn’t do justice to either async-await or promises. For somebody who is new to Javascript making sense of these and decide which one to use can be a challenge. In this post I will list down things that I have learnt about these and how I decide when to use what.
I read somewhere that async-await is syntactical sugar for using promises. So before getting to know async-await or deciding on which approach to you use make sure that you have a better understanding of promises. I captured my learnings in the post Understanding promises in Javascript. If you do not have time to go through the full article checkout the thumb rules that I follow.
Thumb Rules for using Promises
Use promises whenever you are using asynchronous or blocking code.
resolve maps to then and reject maps to catch for all practical purposes.
Make sure to write both .catch and .then methods for all the promises.
If something needs to be done in both the cases use .finally
We only get one shot at mutating each promise.
We can add multiple handlers to a single promise.
The return type of all the methods in Promise object whether they are static methods or prototype methods is again a Promise
In Promise.all the order of the promises are maintained in values variable irrespective of which promise was first resolved.
Once you have wrapped your head around promises checkout async await.It helps you to write code that is much more readable. When not used properly it has its downsides. You can read Understanding async-await in Javascript to checkout my learnings. If you do not have time to read the full article checkout my thumb rules.
Thumb Rules for async-await
Here are a list of thumb rules I use to keep my head sane around using asyncand await
aync functions returns a promise.
async functions use an implicit Promise to return its result. Even if you don’t return a promise explicitly async function makes sure that your code is passed through a promise.
await blocks the code execution within the async function, of which it(await statement) is a part.
There can be multiple await statements within a single async function.
When using async await make sure to use try catch for error handling.
Be extra careful when using await within loops and iterators. You might fall into the trap of writing sequentially executing code when it could have been easily done in parallel.
await is always for a single promise.
Promise creation starts the execution of asynchronous functionality.
await only blocks the code execution within the async function. It only makes sure that next line is executed when the promise resolves. So if an asynchronous activity has already started then await will not have an effect on it.
So should I use promises or async-await
The answer is that we will use both. Following are the thumb rules I use to decide when to use promises and when to use async await
async function returns a promise. The converse is also true. Every function that returns a promise can be considered as async function
await is used for calling an async function and wait for it to resolve or reject.
await blocks the execution of the code within the async function in which it is located.
If the output of function2 is dependent on output of function1 then I use await.
If two functions can be run in parallel create two different async functions and then run them in parallel.
Two run promises in parallel create an array of promises and then use Promise.all(promisesArray)
Every time you use await remember that you are writing blocking code. Over the time we tend to neglect this.
Instead of creating huge async functions with many await asyncFunction() in it, it is better to create smaller async functions. This way we will be aware of not writing too much of blocking code.
Another advantage of using smaller async functions is that you force yourself to think what are the async functions that can be run in parallel.
If your code contains blocking code it is better to make it an asyncfunction. By doing this you are making sure that somebody else can use your function asynchronously.
By making async functions out of blocking code, you are enabling the user who will call your function to decide on the level of asynhronicity he wants.
Hope this helps you decide easily when to use promises and when to use promises and when to use async-await
Originally published on https://hackernoon.com/should-i-use-promises-or-async-await-126ab5c98789
Recently I had thrown a bounty for converting a flat json to a nested json. You can check more about it in the link below
https://steemit.com/@mightypanda provided a solution to the same and won the bounty. I wanted to test the solution for various scenarios. Creating the inputs for the edge cases was very time consuming. I thought of using random generators for testing the same. So I started digging a little bit.
To randomise or not
There is no agreement on using random generators for testing. The argument against using random generators was that the test cases should be deterministic meaning that you should know what is the input and what is the expected output. While this makes sense from the test report and test suites, I though we could use randomised generators for inputs so that we can test the output for hitherto untested inputs every time we want. If used properly this method helps us increase the number of scenarios or inputs for which we can test.
Lets randomise
If you have read my previous article Understanding Promises in Javascript you would remember that we used the getRandomNumber function which served us well for promiseGenerator functions so that we were able to simulate and learn how promises work. I had added a disclaimer saying that //works when both start,end are >=1 and end > start. Since I will be using this method more frequently I thought of cleaning it up a bit.
function getRandomNumber(start = 1, end = 10) {
//works when both start,end are >=1 and end > start
return parseInt(Math.random() * end) % (end-start+1) + start;
}
// Lets add another function which just calls getRandomNumber //function and prints it.
function printRandomNumber(start = 1, end = 10) {
console.log(getRandomNumber.apply(null, arguments));
}
I wanted it to work for positive numbers, one of the params could be zero and even for negative numbers. To find it out if it is truly random(oh I mean’t randomised enough) and if the edge cases are handled we will need to run this getRandomNumber function multiple times. What I mean by that is that if we need to be sure that start and end values are included in the random numbers that are generated the only way forward is that run the function enough number of times until the random number generated is same as start or end. I would put it as occurrence is the only proof that it will occur.
Repeat
So let us create a function which can call the desired function desired number of times. I got the following example from Stackoverflow.
const loop = (fn, times) => {
if (!times) {
return;
}
fn();
loop(fn, times - 1);
};
//Format for invoking our loop function. Let us say we need to call // getRandomNumber function 20 times
loop(printRandomNumber, 20);
Ah that was simple enough. It would have been good if I had thought of it. I think I googled a little early. So this function uses recursion. Exit criteria is that times is not zero. Recursion criteria is that when exit condition is not met invoke the desired function and then call the recursive loop function with times variable decremented. That was simple enough, isn’t it?
But we might have scenarios where we will need to pass parameters to the function in question as well. So let us modify our function a little.
const loop = (fn, times = 5, params = []) => {
if (!times) {
return;
}
fn(...params);
loop(fn, times - 1, params);
};
//Format for invoking our loop function. Let us say we need to call // getRandomNumber function 20 times with start and end values as 2 and 5
loop(printRandomNumber, 20, [2,5]);
So we have added a third parameter to our loop function which will be an array of parameters. When invoking the desired function we are using the spread operatorthree dots to pass the params to the function. We just need to make sure that when passing the parameters to the desired function we pass it as an array of parameter values. Come to think of it, I think we should have named this function as repeat instead of loop.
If we make the times to 100 or so it will be difficult for us to look at the values at one. So let us just create a concatenation function.
outputString = "";
// I know using global variables is bad. For now let us keep it this //way. Once explore the closures completely we can use it for this //scenario.
function concatenateRandomnumber(start = 1, end = 10) {
outputString += getRandomNumber.apply(null, arguments) + ", ";
}
// This will add a trailing comma but who cares. Lets just call in //Stanford comma for now :P
So let us call the above function and with some edge cases and check.
var randomLimits = [0, 3];
loop(concatenateRandomnumber, 100, randomLimits);
console.log(...randomLimits);
console.log(outputString);
fails for zero as 3 is never appearing
var randomLimits = [-3, 3];
loop(concatenateRandomnumber, 100, randomLimits);
console.log(...randomLimits);
console.log(outputString);
Fails for negative range.
Randomise Better
Using loop function we have identified the edge cases where our getRandomNumber is failing. This time I didn’t google. After some though I realised that it is all about getting the range. So I changed the function as follows.
function getRandomNumber(start = 1, end = 10) {
if (start > end) {
[start, end] = [end, start];
}
let range = end - start + 1;
return (parseInt(Math.random() * range) % range) + start;
}
This seems to work for most of the edge cases. Do let me know if I missed something.
Passes for all edge cases considered
Math.random gives random floating numbers between 0 and 1. So (parseInt(Math.random() * range) % range) will give us a random number between 0 and range. I am then displacing it by start to have the radom number generated between start and end.
For this problem statement we know that we will have a flat json and the value of the pos attribute changes only one step at a time. So the increment is only in terms of -1,0,+1 In the solution provided by mightypanda getNestedJSON is the main function and createChild is used internally.
Let us first define runTestforFixedValues function. These are like static inputs for the scenarios that we already know of. Let us check the output.
The solution provided worked for all three input scenarios. Instead of creating more inputs like this. I spent some time on creating the random Flat JSON generator in the required format.
function runTestforRandom() {
var inputArray = [];
let alphabetsArray = [];
for (i = "A".charCodeAt(0); i <= "Z".charCodeAt(0); i++) {
alphabetsArray.push(String.fromCharCode(i));
}
var maxNumberOfElements = getRandomNumber(3, 10);
var inputObject = [];
// All we need is -1,0,-1 just change the number of occurences to //control the likelihood of the value being used. CRUDE //IMPLEMENTATION :P
var incrementArray = [-1, -1, 0, 1, 1, 1, 1, 1];
pos = 1;
inputArray.push({ pos: pos, text: "A" });
for (var i = 1; i < maxNumberOfElements; i++) {
randomNumber = getRandomNumber(1, incrementArray.length) - 1;
increment = incrementArray[randomNumber];
tempValue = pos + increment;
pos = tempValue > 0 ? tempValue : 1;
var obj = new Object();
obj.pos = pos;
obj.text = alphabetsArray[i % 26];
inputArray.push(obj);
}
getNestedJSON(inputArray);
}
I have created alphabetsArray that contains alphabets which we will use for text property. maxNumberOfElements is generated using our random number generator function. We know that between adjacent objects the value of pos changes only by -1,0,+1. So an incrementArray is stuffed with these values and we are picking one of these values randomly. Let us say you want to create a deeply nested object, then increase the occurrences of +1 in this array. We can also make the text field of the object random as well. Since its value doesn’t affect the outcome, we are assigning alphabets in series to textobject so that it is easier for verify if the output is nestified properly. Take a look at the output below to see what I am saying. It is almost as easy as reading alphabets to check if the nesting is proper or not. Even if we had not sued the alphabets in series we could still ready the pos property in these objects to verify the nestifying operation.
Whenever I came across an interesting pattern I just copy pasted the input array from the console and pasted it back in my code for runTestforFixedValues function. Very soon I had a big list of fixed input values like follows.
We could keep repeating the process and increase our inputSets until we have a wide range of input values.
So now we are able to test the code for various static input values. Every time we run the tests we can also look at some random inputs and verify if the output is expected. If you like that input or if you consider that is an edge case that should be tested in general then you can just copy paste that input to your static value testing method. Isn’t that cool? At-least I think it is. I find it very useful when I want to check the logic of a particular critical function.
If you want to look at all of this code in a single place checkout
AudienceProject, a Denmark-based marketing technology company, revealed that nearly 5% of mobile sessions were blocked in the U.S. in 2016. Germany has ranked high in desktop ad-blocking use. The research found that nearly 13% of mobile sessions were blocked in Germany.
There is no denying that ad blockers are putting a big dent in advertising-based business models on the web. And this has produced different reactions. The big question here is who blocks ads, why and how can you win them back.
In this post, we have tried to answer some of the relevant questions asked by publishing firms about ad blocking. This blog will answer questions like who block ads, why do they block it, who does not block ads, how do we win them and strategies to overcome ad blocking in the publishing industry. Check out our previous blog where we have discussed how top 10 Publishers dealing with AdBlocking.
So the question is who block ads?
According to Interactive Advertising Bureau (IAB), nearly 26% of users surveyed block ads on computers and 15% block ads on Smartphones. They tend to be men aged between 18-34 years.
The survey also found that anti-viruses are confused for ad blocking. Around 40% of the user think that they are using an ad blocker. The confusion comes from consumers thinking that antivirus software or pop-up blockers built into their browser are ad blockers.
Now the question arises, why do they block ads?
The answer is: no wants like to get interrupted in between. Especially consumers using ad blockers prefer uninterrupted, quick browsing and a streamlined digital experience. One of the important reason behind using an ad blocker on the personal computer is the perception that websites without ads are easier to navigate.
At the same time, smartphone users believe that ads slow down browsing. In contrast, consumers that are not using ad blockers tend to blame content for slow loading pages.
Some of the most annoying ad elements are ads that block content, long video ads before short videos, ads that follow down the pages as the user scrolls. In the end, it's important to understand ad blocker users are less tolerant of ads.
We often ignore asking ourselves, who does not block ads. Ignoring such questions may not be helpful as you will never know your customers and won’t get the result which you are looking for.
Often past users of ad blockers do not block ads. Readers blocked from accessing the content and messages asking them to unblock in order to view the content often drive then to uninstall the blocker extensions.
The most important question here is how do we win users who block the ad?
Start with implementing “LEAN principle (Light, Encrypted, AdChoice supported, Non-invasive ads)” that address a number of issues related to ad blocking. Further, there are several do’s and don’t that you can follow to win or retain users who block the ad.
Do’s
Give users control to skip the video and/or thumbs up/down ratings.
The other way you can win the user by assuring users of site safety. Ensure them or provide guarantees that site and ads both are secure and virus-free and won’t slow down browsing.
Don’ts:
The biggest often site owners do is they disrupt their flow with ads that block content, long video contents, ads that follow down the page, autoplay, slow loading, pop-ups and full-page ads.
Strategies to overcome ad blocking in the publishing industry
According to a report from PageFair, in 2016, the usage of ad blocker has increased to 30%. The report also found that by the end of 2016, there were 615 million devices blocking ads of which nearly 308 million or 62% were of those mobiles.
For many years, ad blocking has been a major concern among the media and publishing company. But with the advancement in ad-blocking software and extension, it has gone from a mild irritation to a full-blown crisis.
When it comes to overcoming ad blocking in the publishing industry the very first solution that strikes my mind is how to deal with this problem.
Simply put, the solution is to give ad blocker users an ultimatum of whitelisting their website or face paywall. Undoubtedly, this is the best solution for some media and publishing enterprises, however, there are better chances that it may backfire.
In another word, there are chances that users may move to a competitor if they are blocked from accessing the content. Here are some of the strategies publishers can implement to overcome ad blocking.
Go creative or go native
There are two sides to every coin. The emergence of ad blockers is a wake-up call for publishers to become more reader-focused and provide them with easy navigation and enhanced user experience.
Publishers can use the “whitelisting” option to their advantage since most ad blockers provide this option. Ask your reader to white-list your website in order to get access to unique and quality content.
Have less intrusive advertising
Face it. We install ad blockers because some ads are annoying. From my understanding, I am not the only one who either leaves a site or install ad blocker when a page load-delay and obtrusive ads invade on the screen.
On the whole, we all don’t like ads but we understand why are there and as long as they don’t hinder our reading experience, we keep visiting and reading their content.
Aligning ad content more with the page context around them is one of the important characteristics of native ads. Thus, this can be a better option for publishers.
Native ads are less intrusive and do not conflict with a visitor’s experience. In addition, these ads add value for customers that make site visitor view more ad content.
Show your readers that you care about them
By know, we have a brief understanding of - who blocks ads, why, and how to win them back. We also know that big adverts pull people off and make them block ads.
Make your readers feel valued not only by making ads as minimalist and personalized as possible. Also, try to tailor everything else on your site to the reader and build trust by developing a relationship with them. Eventually, this will lead them to either whitelisting your website or pay a fee to read your content.
Strike a deal
In the end, as a publisher, you need to strike a deal with your readers. IAB suggests publishers two innovative approaches: offering tiered access to the content and rewarding them.
Give limited access to users who are using ad blocking software or extension. Communicate with them that more in-depth access is available only after whitelisting the site or turning off the ad blocker.
Reward them by giving credit or other elements to build positive relationships, which will ultimately enhance the trust between the two parties.
Commentary: The above-mentioned method may prove useful, but they are not a permanent solution and a temporary one. The actual solution lies in native advertising, which in most case not blocked by ad-blocker software. However, in the long-term, the solution should involve advertisers to go more creative, safer and privacy compliant and deliver a delightful user experience.
If you are a publishing company looking to increase your ARPU with paid subscriptions, memberships, events, and lead generation we can help. Get in touch with our Drupal experts to find the possible way to boost user engagement on your website.
Voice technology has been with us for many years, but the failing of these systems prevented its adoption globally. However, the recent advances in disruptive technologies like Artificial Intelligence is enabling voice-controlled devices to go mainstream eventually. There is no denying that the technology will have a significant impact on various industries, including media and publishing, to offer personalized services.
By 2020, nearly 55% of US households will have smart devices that mean more than 70 million households will have at least one, TechCrunch reported. The total number of installed devices will top 175 million by that year.
So what exactly is voice technology and why should you consider it for publishing enterprises? Let’s dive in on.
In order to understand voice technology thoroughly, it's important to know about Voice Assistant, Voice Search, Artificial Intelligence (AI) & Machine Learning (ML).
Voice Assistant: These are the software that connects to smart devices and listens to what you say, process it and give a personalized response. They do this by using the different components of AI, such as natural language processing (NLP) and machine learning. Some of the well-known voice assistants are Amazon’s Alexa, Apple’s Siri, Samsung’s S Voice, Microsoft’s Cortana and Google Assistant.
Further, the rise of voice search on digital assistants means an increase in a longer phrase that means audiences don’t need to search with keywords, instead they can ask the questions to search engines. Here publishers/content creators need to optimize their publishing website for voice search to use the technology effectively.
Artificial Intelligence: With the advances in AI, the opportunity seem endless. In layman term, AI is the simulation of human intelligence processes by computer systems. These processes include learning, reasoning, self-correction, speech recognition, machine vision and others. Here, Machine Learning (ML) - an application of AI - enables systems to automatically learn and improve from experience.
So why voice technology for the publishing companies
Voice technology is the changing the way people search the internet for information. A recent survey by Google revealed that nearly 48% of users who own a voice-activated speaker prefers to receive personalized information from recognized brands to make their work and lives easier.
The numbers mentioned above clear that voice technology is soon going to be a new frontier for the publishing industry. And there is no better time to start integrating this technology into your website.
Leveraging the platform
There are two ways the publishing industry can leverage voice technology to the fullest. First, the content should be provided as a news feed through the smart devices using an RSS or XML feed. Second, voice can be used to transform the internal search engines, database products, and mobile applications. The voice-driven search will also enhance search experiences for the audience.
Initiatives by Drupal community around Voice enabled functionality
Drupal VoiceCommander module allows users to navigate the entire menu system of a Drupal website, using the Web Speech API. By implementing this module, users can easily navigate the site without using a mouse, use voice commands on mobile devices and selects their own list of commands from custom menus. Additionally, using Drupal voice search module, you can seamlessly add speech recognition to your web pages to search for content.
It's clear that voice technology is the new frontier and publishing industry needs to experiment with voice. There is no denying that media and publishing companies are constantly trying to ensure enhanced and personalized user experience. However, such work requires a dedicated IT team to monitor the developments and work accordingly.
Give a shout out to Valuebound if you would like to see how we can help you to understand the business side of it.
Getting your ad viewed by targeted audience shouldn't be a struggle when you are putting your best efforts on it. Also, it is not even a click-through or a conversion. Still why it is considered a win if half the ad is visible for a second or two.
Ad viewability plays a critical role in the performance of your website and business. These are greatly linked to revenue and increasing it can significantly result in a better RoI.
For publishers, agencies, and marketers, viewability has always remained a hot topic. A low viewability rating shows that you, the publisher, need to reassess and adapt ad positions.
Let’s cut through the clutter and discuss some of the best practices that can help publishers enhance ad viewability and increase revenue.
Page length
According to Google, the short form of contents are tend to have higher viewability. Shorter contents are easy to consume if your pages have only a single fold. You can also enable infinite control if you wish to post longer content.
Load speed
Websites filled with ads are naturally associated with a high load time. Google suggests brands should make sure their webpage is loading fast, including ad rendering time. In such circumstances, performance optimization is recommended as both user experience and usability are dependent on the speed of page loads.
Alternatively, leverage Google Pagespeed - speed optimization tool - to analyze and optimize website performance.
Design responsiveness
Responsive design ensure that ads will adapt to the browser and device used for viewing those ads. Responsive ads not only provides a better user experience but also enhances the viewability. This move can help you improve the viewability of ads and business revenue.
Sidebar content
Responsive templates are a great way to enhance user experience and boost viewability. However, you should know how your sidebar content is presented in each template. In certain scenarios, an ad might not be visible when you amplify the content. Make sure sidebar content has optimum visibility even when users zoom in on your page.
Optimize your viewability
Ad placement matters. Placement of ads just above the fold has proved the best place for the highest viewability rates. Google suggests to place the ad right above the fold and not at the top of the page. Further, the most viewable ad sizes are the vertical size units such as 160x600.
Produce great content
Content is king. While there is various other recommendation on ways to improve viewability, one of the key components is content. Readers love unique and quality content. The quality content decides whether an ad will be seen is if a person is willing to invest his/her time with it.
Measuring your performance
Well, there is n number of practices that help you to stay ahead of your competition. And measuring your ads performance is one of them. It helps you to see how you are currently performing in terms of viewability. Don’t forget to closely track each metrics.
Measuring ads performance gives you an opportunity to work and improvise them. Most importantly, there are two metrics you need to look at - placement and creative sizes.
Bottom line: Viewability is a challenge for both buyers and sellers. Optimizing the ads accordingly helps you to bring better results, build a long-term relationship and drive more revenue. Hence, we suggest not to just take our advice but test, learn and let the data drive your decisions.
Hope you have enjoyed reading the list of viewability tips! Be sure to implement and test each one for the best results. If you want our Drupal team to take a look at your website and provide you with a few personalized insights. Contact us.
I think npm was one of the reasons for quick adoption of nodejs. As of writing this article there are close 7,00,000 packages on npm. If you want more details about packages across different platforms you can checkout http://www.modulecounts.com/ I know it is comparing apples to organges when comparing packages across different platforms. But at-least it should give you some sense of adoption of node and javascript.
npm package growth
Finding the right node package
Since there are so many packages we have a problem of plenty. For any given scenario we have multiple packages and it becomes difficult to identify the right fit for your use case. I generally look up github repos of popular projects to finalise which package to use. This may not scale up always and need more work.
So I have stuck to using http://npms.io/ for now. It has better search features and also has rating of various packages based on different parameters. You can read the rating logic on https://npms.io/about
For example if you want to use twitter api packages you can search for the same which gives you an output like
Do let me know if there is a curated list of node packages or some help groups which help us identify the right packages.
Using additional features of npm
If you are a node developer I am pretty sure that you have already used npm and you are comfortable with the popular commands npm init andnpm install So let us look at a few other handy commands and features.
Since there are more than 7,00,000 packages in node I wanted to make sure that there was a simple way to keep track of my favourite packages. There seems to be a way but not very user friendly.
From the interface I didn’t find any option to start my favorite packages. For now looks like we will have to make do with npm cli.
Login on command line with your credentials.
npm login
One you hit the command enter your credentials. Currently it asks for email id which is public. I think npm figures out a way to mask the user email ids. I am not comfortable sharing my email id.
npm login
Once you are logged in, you can checkout if it was successful using the whoami command.
npm whoami
outptu of whoami
Starring a package
npm star axios
Starring a package
If you want a list of packages you have starred then you can use npm stars
npm stars
The command gives you the output like show in the above image.
If you want the complete dependency list you can use npm list which gives a tree output like below.
npm list tree view
Most of the times this is overwhelming and the first level packages should be a good enough check.
npm list --depth=0 2>/dev/null
If you use the above command you will get the list of first level packages in your project.
npm list first level
To go global or not
As a rule of thumb I have tried to reduce the number of packages I install globally. It always makes sense to install the packages locally as long as they are related to the project. I only consider installing a package globally if its utility is beyond the project or has nothing to do with the project. You can run the following command to see your list of globally installed packages.
npm list -g --depth=0 2>/dev/null
In my case the output is
npm list global packages
As you can see from the list most of the packages are general purpose and have got nothing to do with individual projects. I am not sure why I installed jshint globally. My atom editor is setup with jshint and I think that should be sufficient. I will spend some time over the weekend to see why I did that.
Security Audit
In latest npm versions if there are any security concerns they get displayed when you run npm install command. But if you want to do an audit of your existing packages run npm audit
npm audit
This command gives you details of vulnerabilities in the package. It gives you details of the path so that you can judge the potential damage if any. If you want more details you can checkout the node security advisory.
You can run a command like npm update fsevents — depth 3 to fix the individual vulnerabilities as suggested or you can run npm audit fix to fix all the vulnerabilities at once like I did.
npm audit fix
NPX
Another problem that I have faced with installing packages globally is that every time I run one of these packages it would have a latest version released. So it kind of doesn’t much sense to install them in the first place. npx comes to your rescue.
To know more about npx read the following article.
For example to run mocha on a instance all you need to do is npx mocha Isn’t that cool. The packages you saw on my instance are the ones that I had installed before coming across npx I haven’t installed any packages globally once I started using npx.
Licence crawler
Let us look at one sample use case for using npx While most of the packages on npm are generally under MIT licence, it is better to take a look at the licences of all the packages when you are working on a project for your company.
npx npm-license-crawler
npm licence details
npm, yarn or pnpm
Well npm is not the only option out there. You have yarn and pnpm which are popular alternatives. Yarn was more like a wrapper around npm by facebook for addressing the shortcomings of npm. With competition heating up npm has been quick in implementing the features from yarn. If you are worried about disk space you can use pnpm. If you want a detailed comparison of these three you can checkout https://www.voitanos.io/blog/npm-yarn-pnpm-which-package-manager-should-you-use-for-sharepoint-framework-projects
There is a lot of buzz around ad viewability nowadays. In the world of digital marketing, it has become such a hot topic that every firm is looking to build their presence online. But what exactly does it mean to be “viewable”? Does this mean people will look at your ad? Or is it a silver bullet industry is looking for?
Let’s solve this puzzle. In this post, we will discuss everything you need to know about ad viewability such as:
What is viewability?
Why is viewability important?
When is an ad impression not viewable?
Best practices to enhance viewability to increase views
How to measure viewable impressions?
Let’s begin with the basics, what is ad viewability?
Ad viewability is the concept of showing how visible your ad is on a website and to users. In other words, viewability is an online advertising metrics that tracks only impressions actually seen by users.
Why is viewability important?
High viewability rate indicates a high-quality placement, which can be valuable to advertisers as a Key Performance Indicator (KPI). The ad viewability helps marketers to calculate the relative success (click through ration or CTR) of a campaign by dividing the number of ads served by the number of clicks.
Also, there are other factors that contribute to an ad not being seen such as users clicking away from a page before the ad loaded or even bots or proxy servers opening pages, rather than live human beings.
When is an ad impression not viewable?
There is an assumption that header spots - placements that appear before the content the user has selected representing the placement with the best viewability. Simultaneously, the ad which is placed somewhere in the middle of the site or near to the relevant part of the content is an attractive alternative. These places represent a good compromise in the ration between price and viewability.
For instance, if an ad is loaded at below the fold (bottom of a webpage) but a reader doesn’t scroll down far to see it then impression will not be considered viewable.
According to Google, the ad should be placed right above the fold and not at the top of the page. The most viewable ad sizes are the vertical size units such as 160x600.
Best practices to enhance viewability to increase views
Much has been talked about the best practices, but it never sums up. Publishers talk about diversifying their revenues. And evidently, some of them have managed to achieve the success particularly those who have focussed on it for a while.
Being a publishing firm, it's always suggested to start with user persona followed by designing web pages in such a way that the ads load with maximum viewability.
Try to design a web page where the ad unit will appear “above the fold” or a “sticky ad unit”. Sticky ad units are a type of ad that remains locked in a specific location when the user scrolls.
Another key consideration for ad viewability is speed. Sites that are laden with ads from multiple ad networks can typically take a long time to load. Consider applying techniques that can speed up ad delivery can greatly improve ad viewability.
Here are some of the best practices that can help you to enhance ad viewability and increase Revenue.
Digiday quoted Jim Norton, the former chief business officer at Condé Nast, saying “No single stream of alternative revenue will make up for the declines that we’re seeing in advertising,” said.
How to measure viewable impressions?
According to the Interactive Advertising Bureau (IAB), an ad which appears at least 50 percent on screen for one second or longer for display ads and two seconds or longer for video ads is considered as a viewable impression.
Bottomline: Buying a "viewable" ad impression does not guarantee that it's going to be seen and/or clicked on. However, there are several other ways you can ensure the chances of your ad being viewed. It’s also important to understand the different metrics that online ad success cannot be determined by views and clicks alone. Furthermore, you need to consider the entire buyer journey.
If you are a publishing firm looking for experts to integrate the needs of a publishing platform with Drupal we can help. Get in touch.
There is a lot of buzz around ad viewability nowadays. In the world of digital marketing, it has become such a hot topic that every firm is looking to build their presence online. But what exactly does it mean to be “viewable”? Does this mean people will look at your ad? Or is it a silver bullet industry is looking for?
Let’s solve this puzzle. In this post, we will discuss everything you need to know about ad viewability such as:
What is viewability?
Why is viewability important?
When is an ad impression not viewable?
Best practices to enhance viewability to increase views
How to measure viewable impressions?
Let’s begin with the basics, what is viewability?
Ad viewability is the concept of showing how visible your ad is on a website and to users. In other words, viewability is an online advertising metrics that tracks only impressions actually seen by users.
Why is viewability important?
High viewability rate indicates a high-quality placement, which can be valuable to advertisers as a Key Performance Indicator (KPI). The ad viewability helps marketers to calculate the relative success (click through ration or CTR) of a campaign by dividing the number of ads served by the number of clicks.
Also, there are other factors that contribute to an ad not being seen such as users clicking away from a page before the ad loaded or even bots or proxy servers opening pages, rather than live human beings.
When is an ad impression not viewable?
There is an assumption that header spots - placements that appear before the content the user has selected representing the placement with the best viewability. Simultaneously, the ad which is placed somewhere in the middle of the site or near to the relevant part of the content is an attractive alternative. These places represent a good compromise in the ration between price and viewability.
For instance, if an ad is loaded at below the fold (bottom of a webpage) but a reader doesn’t scroll down far to see it then impression will not be considered viewable.
According to Google, the ad should be placed right above the fold and not at the top of the page. The most viewable ad sizes are the vertical size units such as 160x600.
Best practices to enhance viewability to increase views
Much has been talked about the best practices, but it never sums up. Publishers talk about diversifying their revenues. And evidently, some of them have managed to achieve the success particularly those who have focussed on it for a while.
Being a publishing firm, it's always suggested to start with user persona followed by designing web pages in such a way that the ads load with maximum viewability.
Try to design a web page where the ad unit will appear “above the fold” or a “sticky ad unit”. Sticky ad units are a type of ad that remains locked in a specific location when the user scrolls.
Another key consideration for ad viewability is speed. Sites that are laden with ads from multiple ad networks can typically take a long time to load. Consider applying techniques that can speed up ad delivery can greatly improve ad viewability.
Here are some of the best practices that can help you to enhance ad viewability and increase Revenue.
Digiday quoted Jim Norton, the former chief business officer at Condé Nast, saying “No single stream of alternative revenue will make up for the declines that we’re seeing in advertising,” said.
How to measure viewable impressions?
According to the Interactive Advertising Bureau (IAB), an ad which appears at least 50 percent on screen for one second or longer for display ads and two seconds or longer for video ads is considered as a viewable impression.
Bottomline: Buying a "viewable" ad impression does not guarantee that it's going to be seen and/or clicked on. However, there are several other ways you can ensure the chances of your ad being viewed. It’s also important to understand the different metrics that online ad success cannot be determined by views and clicks alone. Furthermore, you need to consider the entire buyer journey.
If you are a publishing firm looking for experts to integrate the needs of a publishing platform with Drupal we can help. Get in touch.
With the advances in technology, automation is playing a key role in software development processes as it enables the team to verify regression test, functionality and run tests simultaneously in most efficient way. Note that technology is no longer stable and continuously evolves. Similarly, web-based applications like Drupal and other frameworks consistently enhance the tools in order to grab the market attention. Further, automation is when compared to the best choice for web-based applications as verifying and testing the application interfaces are comparatively easier than previous web applications.
Before we talk about Behaviour Driven Development (BDD), let’s have a look at why automated tests.
Improves speed
Better Test Coverage
Better efficiency
Boosts Developers & Testers Morale
Require less human resources
Cost efficient
What is BDD?
BDD is a methodology that is used to develop softwares/projects through example-based communication between developers, QA, Project Managers and business team.
The primary goal of BDD is to improve communication between business team by understanding functional requirements from all the members of development team to avoid ambiguities of requirements. This methodology helps in delivering software that assists in continuous communication, deliberate discovery and test-automation.
Why should we follow BDD methodology?
BDD is an extension of TDD (Test Driven Development). Like in TDD, in BDD also we test first and add application code. This is easy to describe using ubiquitous language.
Further, BDD follows example based communication process between teams, QA and business clients.
Example Based Communication
This helps business team and developers to clearly understand the clients requirement. BDD is largely facilitated through the use of domain specific language by using natural language constructs.
Gherkin
It represents “Defining behavior” writing features using gherkin language. Behat is a tool to test the behavior of your application which is described in a special language called gherkin especially for behavior descriptions.
Gherkin Structure
Behat is a BDD (Behavior Driven Development) for PHP framework for auto testing your business expectations. Behat is used to check the test cases written in Gherkin structure.
Example structure of Feature File:
Gherkin keywords and its descriptions as follows: Feature: This is a descriptive section of what is desired starts the feature and gives it a title. Behat doesn’t parse next 3 lines of text which specifies the context to the people reading your feature. Scenario: This is something like determinable business situation starts the scenario, it contains description of the scenario. Steps: Feature consists of steps known as Givens, Whens and Thens. Behat doesn’t technically differentiate between these three kind of steps.
Each feature file can contain single scenario to test the behavior of our application. Similarly, feature file can have multiple scenarios to test the behavior. Given: It defines the initial state of the system for the scenario. When: This describes the action taken by the person/role. Then: Describes the observable system state after the action has been performed.
And/But: Can be added to create multiples of Given/When/Then lines.
Prerequisites:
PHP higher than 5.3.5
Libraries should install “curl, mbstring, xml” (Behat is a library it can be easily installed by using composer)
Installing Behat
Step 1: Follow the commands in terminal to create composer.json file. Install behat in any path wherever you want... let’s say in root folder path.
If you want to test javascript testing with Selenium, you can install with selenium2-driver else it is not required to install.
Start using Behat in your project to call vendor/bin/behat --init. This will setup a features directory in behat directory.
Step 2: Open FeatureContext.php file under /behat/features/bootstrap after that run “init command” and add the below code snippet.
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext;
Step 3: Extend your FeatureContext class with MinkContext and implement with SnippetAcceptingContext and Context.
Step 4: Now create a config file called behat.yml in behat directory
We should specify the base URL to test which instance by behat in behat.yml file.
Goutte driver will act as a bridge between behat and your business application.
Wd_host is nothing but the localhost URL so it can be 127.0.0.1:4444/wd/hub for Selenium integration with behat.
Note: If you want to test with Selenium integration, you should downgrade your Firefox version to 46. Selenium standalone server version should be 2.52.0 and your Firefox driver should be geckodriver version 0.17.0. Just download the zip file as it is enough to start the Selenium server.
Currently, Selenium integration successfully working in firefox version 46 with appropriate other Firefox drivers. If you want to test with Firefox means you should change browser_name: firefox in behat.yml file.
In feature file, we should mention “@javascript” before scenario starts then only it will recognize the Selenium server to start browser testing.
Starting Selenium server
Start Selenium server for javascript testing
java -Dwebdriver.GeckoDriver.driver="GeckoDriverdriver" -jar selenium-server-standalone-2.52.0.jar to start selenium server
(or)
java -jar selenium-server-standalone-2.44.0.jar
Don’t forget to specify @javascript in feature file to run Selenium testing.
Create feature file under /behat/features/login.feature
Once done with features, scenarios, and steps. Finally, run the feature file in terminal. Path should be your application where installed: vendor/bin/behat this will run all features scripts.
You can also run single feature file like vendor/bin/behat features/file_name.feature.
If you want to run the Selenium javascript testing with slow time monitoring you can do like this (scenario will be like “And I wait for 2”)
“iWaitFor” function is nothing but a step, which is defined in feature file like “And I wait for 2” number specified as in seconds.
Similarly, I have given example here for triggering “Enter” keyboard button.
vendor/bin/behat -dl this command will show all the list of behat availability options
Sample output:
We have covered the detailed descriptions of behavior driven development followed up by example based communication between teams, QA, and business clients. We also touched Gherkin structure, usage of behat tool and installation procedures. This should have give you the overall idea about javascript automation testing. Feel free to share your experiences and any issue you come across.
Below given is a presentation on "Behavior Driven Development".
Media and publishing companies typically run their business based on segmented revenue streams, like advertising, promotions etc. Here revenue stream often reports vertically to ensure the steep rise in global annual turnover. But could it be the right time for the publisher to focus on paid ARPU, subscription and memberships?
Thanks to major content players like Netflix, Amazon, Spotify and the other who have leveraged subscription model and proved users are willing to pay for the quality content. Perhaps, it’s high time when the publishing industry should focus more on fixing their business model and less on ways to further enhance the content production.
We are, in the simplest terms, a subscription-first business. Our focus on subscribers sets us apart in crucial ways from many other media organizations. We are not trying to maximize clicks and sell low-margin advertising against them. We are not trying to win a pageviews arms race. We believe that the more sound business strategy for The Times is to provide journalism so strong that several million people around the world are willing to pay for it.
With this, the question arises - how these organizations are increasing their ARPU with paid subscriptions, memberships, events, and lead generation.
First, publishers need to work on their content strategy and user experience to boost audience engagement. Simultaneously, they need to consider their audience base and figure out their goal. They can also think about - what is the unique value proposition you can offer to your client? And how to ensure they are aware of it?
Of course, here, introducing a premium model should be the first step, but more needs to be done if the transition is to be successful. Let’s have a look at four key areas publishing houses can work on.
Paid Subscription: Publishers are turning directly to site viewers for paid subscriptions rather than relying on advertising. Typically, a subscription model requires users to pay money to get access to a product or service. It works best when the company provides highly specialized and unique information that readers can’t find anywhere else.
Membership: A membership is the notion of belonging. It says nothing of cost or price, though most memberships end up having a cost to them. Membership programs are exclusive as it has tremendous benefits. Being a valuable member gets you access to other members – which may be the thing that is most valued.
Events: Hosting events to diversify revenue streams is nothing new. Often event organizers combine their resources showcasing the magazine’s content as part of a unique offering. A planned occasion not only provides an additional revenue stream but also increases subscribers base. According to the American Press Institute, “Incorporating an events strategy with publishing also strengthens a publisher’s brand and bottom line while deepening connections with audiences, sponsors, and advertisers.”
Lead Generation: It typically starts with data collection pushing prospects to landing pages and asking them to fill lead-gen collection forms to get free ebooks, whitepaper, and other resources. These data are used to better understand the leads, engage with them and enhance lead-gen programs. Here, email marketing helps publishers to reach their targeted audience.
Further, publishers can utilize proven online marketing methods, such as webinars, co-registration, affiliate partnerships, search engine optimization and others.
Are you interested in getting a subscription feature for your own website to provide services to your customers? Not only we help you in keeping track of customers and their subscriptions, but we also handle end-to-end Drupal management services. Get in touch with our experts to find out how you can use the subscription model to increase your ARPU.