Shopify (SHOP -1.05%) notched explosive gains over the past week of trading, thanks to a very strong quarterly report. The e-commerce specialist's share price surged 26.2% higher across the stretch. Over the same period, the S&P 500 rose 2.4%, and the Nasdaq Composite jumped 3.9%.

Shopify published its Q2 results before the market opened on Aug. 6, and the report arrived with a substantial sales beat that helped power big gains for the stock. The company's share price is now up roughly 41% year to date.

A dollar sign in a sea of charts.

Image source: Getty Images.

Shopify surges on strong Q2 results

In the second quarter, Shopify recorded net income of $906 million on sales of $2.68 billion. Revenue came in roughly $130 million ahead of the average Wall Street analyst estimate. Meanwhile, earnings per share of $0.35 beat the average analyst estimate by $0.06 per share, and the role that artificial intelligence (AI) played in powering sales and margin improvements also helped increase bullish sentiment surrounding the stock.

Shopify's revenue increased 30.7% year over over in the second quarter, with gross merchandise volume conducted through the company's platform rising 31% annually to hit $87.8 billion. Monthly recurring revenue rose roughly 9.5% year over year to reach $185 million, and the business posted free cash flow of $422 million, good for a margin of roughly 16%.

What's next for Shopify?

For the third quarter, Shopify is guiding for a mid- to high-percentage sales growth rate. Meanwhile, the business's gross profit is expected to increase a low-20s-percentage rate, and operating expenses are expected to rise to between 38% and 39% of revenue in light of increased marketing spending, employee compensation, and other factors. The company expects that its free-cash-flow margin for the period will come in at a mid- to high-teens percentage.

Shopify stock looks riskier now that recent gains have pushed its forward price-to-earnings ratio up to roughly 104, but the company has undoubtedly been serving up strong business results lately.