When you invest in dividend stocks, you're normally doing so because you want a recurring payout. But in some cases, you can also set yourself up for some potential gains as well. This year, investors have been pivoting toward big artificial intelligence stocks and have dumped some quality investments along the way.

A couple of stocks that are down more than 20% this year and pay dividends -- and have upside of more than 50% according to Wall Street analysts -- are Royalty Pharma (RPRX -0.39%) and JD.com (JD 6.12%). Here's why you should consider adding these stocks to your portfolio today.

1. Royalty Pharma

Healthcare company Royalty Pharma provides investors with an attractive dividend yield of 2.6%,which is over a full percentage point higher than the S&P 500 average of 1.5%. What makes the stock an attractive investment option is that it relies on royalties from some of the healthcare industry's top drugs. The bulk of the company's royalty revenue comes from cystic fibrosis drugs, which during the first three months of the year generated $204.5 million in royalty revenue and represented 31% of Royalty Pharma's top line.

While Royalty Pharma's business may be stable in that it relies on revenue from a wide range of drugs, the business itself may not be terribly exciting, especially in the midst of a market rally this year when investors have been buying up more promising growth stocks

Down 21% year to date, the stock's decline has been gradual; there hasn't been a sharp sell-off leading to its underwhelming performance this year. But analysts remain optimistic that the stock could be a good buy. The consensus analyst price target is $54, which is more than 70% higher than where the stock trades at right now.

With the stock trading at only eight times its estimated future earnings, there's a lot of value with Royalty Pharma today. Investors can not only secure a high dividend yield, but also take advantage of a relatively low valuation.

2. JD.com

If you're craving a bit more growth potential, then JD.com might be a better investment to consider over the long run. The Chinese e-commerce company is one of the top online retailers in the country. JD.com is also focused on the future, and has been investing in drones and robot delivery services to help improve performance and reach consumers in rural areas.

While COVID lockdowns have weighed on the business in recent years, the company's long-term trajectory remains promising -- the Chinese economy grew by 6.3% in the second quarter after achieving a 4.5% growth rate a quarter earlier. Although it's not as fast as analysts anticipated, it's a positive sign that the economy could still do much better, which bodes well for JD.com.

Concerns surrounding worsening Chinese-U.S. relations, however, have weighed on the stock's valuation, and it's down 34% this year. But at a forward price-to-earnings multiple of 12, this too is a significantly undervalued stock to own right now. There is going to be some risk for investors given the uncertainty around the Chinese market, but in the long run the company offers lots of growth potential.

The consensus analyst price target is over $57, which implies an upside of around 55% from the stock's current valuation. That upside, along with a dividend yield of 1.7%, makes JD.com a good buy for long-term investors.