Have you ever noticed an ad on your smartphone or tablet and wondered how it got there? Or opened a game or a video and asked yourself how the app or mobile browser determines which products it should advertise to you? For every ad that appears in your mobile browser or in a mobile app you’ve installed on your device, an ad network and an advertiser have carefully considered where they’d like to promote a product and to what kind of customer they’d like to advertise it to, and concluded that you were a match based on information about your mobile device and your activity on it.

Typically, the path an ad takes to your Android phone or your iPad starts with an ad network, a company that matches ad space from publishers with demand from advertisers. Facebook, for example, has a mobile ad network, called the Audience Network, which enables companies to place ads not only on Facebook, but in a network of other apps, as well. Other examples of ad networks that place the ads you see on a daily basis are Twitter’s MoPub and Google’s AdMob.

But showing ads to mobile users is a much more sophisticated business than just choosing an app where’d you like to display your ad. Instead, ad networks and their advertisers use a variety of ad targeting methods to figure out which users to show an ad. They do that by detecting and taking into account a variety of different pieces of information about you and what you’re doing on your smartphone or tablet.

A 2014 blog post by mobiThinking outlined some of the properties that ad targeting methods take into account when gleaning information about the mobile device, and therefore the user. Useful information includes the device type (are you looking at the ad on a smartphone or a tablet?), device model (should you be seeing ads for iOS or Android apps?), properties like screen size and type (to determine what size to display the ad, and whether or not you have a touchscreen to interact with it), connectivity information (are you connected via WiFi or 4G?), location (which can be detected directly via GPS, or triangulated via cell tower or WiFi hotspot), and data from mobile sensors. These types of data are useful when targeting ads at mobile users, since businesses might want to target consumers based on the type of content they’re looking at, or show an ad to people who are within a certain radius of a store.

Media Thirst explained some of the common strategies behind ad targeting — the strategies for applying the information that ad networks can detect. These are the basic methods for getting ads to the right people, methods that were developed as online advertising for the desktop came into its own. One of those methods is contextual targeting, which matches ads to web pages with content that’s relevant to the product; another is audience targeting, which using behavioral or historical tracking data to match ads to specific people who are likely to be interested in the product.

Broad-spectrum targeting sees businesses placing ads in demographically diverse publications to drive business among a general population. Geo-targeting displays ads based on users’ specific location or general area, while geo-fencing targets users at precise longitudes and latitudes. Action-specific, location-aware targeting displays ads based on user inquiries made in specific locations.

While these methods all work for desktop advertising, they rely on files called cookies. A cookie is a small packet of data that tracks you from website to website — a text file that websites place on your computer the first time you visit them. Cookies tell websites when and how often you return to the site. They track your movements within the site, and let you save information like a shopping cart, site preferences, or even a login, or some kind of personalization.

Mobile browsers and even mobile apps that are essentially web apps packaged as native apps use cookies, too. Apps can send the data packets to a server just like a website does, but the picture into which those mobile cookies fit is significantly more complex on mobile devices than on a traditional desktop computer. On a mobile device, cookies need to inhabit not only the mobile browser, but also a user’s mobile apps to get a complete picture of the scope of a user’s activity. On a smartphone or a tablet, the browser runs in a separate “sandbox” from the environment for the mobile apps installed on the device, and each of those apps is, in turn, isolated from the others, so a tracking mechanism for one is unaware of your activity in the others.

So far, it’s been largely impossible for cookies to track a user’s activity across all of the things they do on their mobile devices, which makes it difficult to accurately target advertising on mobile devices. It also means that when users enter privacy preferences, like opting out of tracking, in one app, the other apps or the mobile browser aren’t likely to respect the preference because the ad networks can’t recognize the instances of user interaction as the same user.

But it seems that ad targeting technology is catching up, and that some of those problems are about to change. Ad Age reports that Google is set to begin testing a new method of targeting smartphone and tablet users that connects the tracking mechanisms for what people do on the mobile web with those that follow what people do in mobile apps. Because such a solution hasn’t yet been implemented, advertisers usually have to treat one mobile user as two, since they haven’t been able to connect what you do in a mobile browser with what you do in apps.

A spokesman told Ad Age that the method Google is testing will enable businesses to “run consistent ad campaigns across a device’s mobile browser and mobile apps, using existing anonymous identifiers, while enabling people to use the established privacy controls on Android and iOS.” The method relies on Google’s network of more than two million third-party sites and its AdMob mobile app ad network, which serves ads to users of “hundreds of thousands” of Android and iOS apps.

The new mobile ad-targeting method reportedly connects the cookie from the mobile web browser with the equivalent of a cookie for mobile apps. Once the two are connected, Google’s tracking will be much more capable. It would, as an example, be able to recognize if you saw one ad in a mobile app, and then show you a follow-up ad on a mobile website. The targeting method reportedly doesn’t involve users’ personal information, and they’ll be able to opt out of tracking in apps or on mobile websites.

Facebook, another big player in the mobile ad space, is addressing another big challenge with mobile advertising, one that Google hasn’t yet solved: the difficulty of tracking what users do across devices. Traditionally, ad networks have been unable to tell when you click on an ad on your iPhone, and then later make a purchase on your computer. As far as their tracking could tell, you saw or clicked on ad and didn’t make a purchase, even if later you navigated to the company’s website on a different device and purchased the product you saw advertised.

But Facebook announced last year that its ad network was rolling out “cross-device reporting,” tracking that will enable advertisers to see which device you were on when you saw a Facebook ad, and which device you used when you bought the product. The tracking uses a piece of code called a “conversion pixel,” which advertisers can insert into their app or site to see which of their ads consumers were exposed to. Facebook explains:

“Imagine seeing an ad for a product on your mobile phone while in line at the bank. Do you immediately make a purchase on your phone? Probably not. But perhaps you go back to your office later that day and buy on your desktop computer. Such cross-device conversions are becoming increasingly common as people move between their phones, tablets and desktop computers to interact with businesses.”

Facebook claims that 32 percent of users who showed interest in a mobile ad on Facebook converted — made a purchase — within 28 days, and cross-device reporting will make it easier for advertisers to understand how mobile ads result in cross-device conversions.

And while Facebook’s cross-device tracking will work because its platforms are so widely used on smartphones, tablets, and desktops, it’s expected that companies like Google, Apple, and Amazon will join Facebook in taking advantage of a shift from cookie-based tracking, which really only works well when consumers are viewing ads exclusively on the desktop, to universal IDs, which will enable each of these companies to track users’ exposure to advertising across devices.

The challenges with cookies opened the way for Twitter and Facebook to anchor users’ identity to registered user accounts, which can then connect their activity across sites, apps, even platforms.

More sophisticated tracking of how users interact with ads will allow advertisers to much more effectively control how often users see their ads, and where they seem them. And while no one’s happy to read about how their information gets used for advertising, you can at least look forward to no longer seeing repetitive ads, and perhaps to seeing ads that are smarter, more location-aware, and maybe even more useful.

[mediagraph-partner content_url=”c3d1f79f983757e8820f3221″][/mediagraph]

More from Tech Cheat Sheet: