Source: The Motley Fool.

Google (GOOG -2.47%) (GOOGL -2.44%) stock was having an uninspiring year in 2015. Shares of the online search giant were basically flat, as investors were getting disappointed with Google's financial performance over the past several quarters. However, things took a dramatic turn when Google reported rock-solid earnings for the second quarter of 2015 last week, gaining a staggering 16% in a single day and making new historical records for Google stock.

Let's look at the main reasons Google delivered such an explosive gain in a relatively short period of time, and, more importantly, whether the company still offers upside potential from current levels or if the best is already in the past for investors in Google stock.

Google is still growing rapidly
Google is in the midst of a transformation. The online advertising industry is going through major changes because of powerful emerging trends such as the rise of mobile computing and increasing online video consumption, factors that are changing industry dynamics.  

Transformations are seldom easy, and Google's revenue growth has been hurt by declining ad prices, since channels such as mobile and YouTube typically mean lower average prices per ad. Besides, rising costs, as the company invests huge sums of money on all kind of growth initiatives, have taken their toll on profit margins. 

But Google dissipated a lot of concerns when it announced financial results for the second quarter of 2015. Not only did earnings come in ahead of Wall Street expectations, but management also highlighted some remarkably encouraging trends, which bode well for investors in Google stock over the years ahead.

Total revenue during the second quarter of 2015 came in at $17.7 billion, an 11% year-over-year increase. Unfavorable currency movements were a major headwind during the period, since total revenue in constant currency jumped by an impressive 18% versus the same quarter in the prior year. This growth rate is nothing short of extraordinary for a company as big as Google.

Margins are improving, too: Traffic acquisition costs declined to 19% of revenue from 21% in the second quarter of 2014, and the company managed to contain operating costs at reasonable levels, so adjusted operating margin rose from 32% of sales to 34% of revenue in the last quarter.

Promising trends
The latest quarter was the first time ever that Google's new CFO, Ruth Porat, led the company's earnings conference call, and what she had to say sounded like music to investors' ears. To begin with, Google is being more disciplined when it comes to investments and expenditures, which should drive higher profit margins over the coming quarters.

In Porat's own words:

The sequential deceleration in expense growth achieved in the second quarter reflects in part the benefit of expense discipline discussed in prior calls. A key focus is on the levers within our control to manage the pace of expenses while still ensuring and supporting our growth. We will do this while we continue to invest in engineering talent to keep us preeminent in innovation globally.

The company is also making big inroads in mobile, reducing the price gap between desktop and mobile ads via an improved user experience and enhanced ad quality. This is another major positive for investors, since it indicates that Google will be able to sustain its enormously profitable business model under the mobile computing paradigm.

According to management, more Google searches are taking place on mobile devices than on desktop in 10 countries, including the U.S. and Japan, two of Google's biggest markets. The company calculates that 30% of mobile queries are related to a specific location, which provides plenty of opportunities for growth and monetization in local search.

Also, YouTube is firing on all cylinders and consolidating Google's position as a top player in online video. Watch time on YouTube was up by a staggering 60% year over year during the last quarter, the fastest growth rate the platform has seen in the past couple of years. YouTube mobile watch time more than doubled from the same period in 2014, so YouTube is rapidly expanding on mobile devices, too.

Advertising dollars are going in the same direction as consumers' eyeballs. As more viewers are increasingly going online for their video content, advertisers are jumping in to capitalize on the opportunity. The number of advertisers running video ads on YouTube is up more than 40% year over year, and the average spend among the 100 top advertisers is up by 60% versus the same quarter last year.

The stock is priced at a moderate premium versus the overall market: Google stock trades at a forward P/E ratio near 21, while the average company in the S&P 500 carries a forward P/E ratio in the neighborhood of 18. Still, this doesn't sound like an excessive price tag to pay for such a leading growth company.

The way things are going, it looks like Google is well positioned for sustained growth over the years ahead, and current valuation levels provide attractive upside room for investors in Google stock.