Use Google's AdWord Conversion Tracking system and PayPal's IPN system to track sales made from Google advertising.
Google has emerged from the search engine wars as the clear winner to date. Its fast, accurate search results are presented in a way that enables users to get search results quickly without the tool getting in the way, unlike many other search engine portals. It is the most widely used search engine on the Internet, and its builders continue to innovate.
Among those innovations is a self-service advertising system that enables small merchants to get wide exposure in a cost-effective, pay-per-click arrangement. When a web surfer looking for an item?a widget, say?goes to Google and types the name of the product into the search box, not only are the search results from the Google Page Ranking system displayed, but so are small, text-based ads related to widgets. As a widget vendor, you can target your AdWords ads to be displayed when a surfer enters certain widget-centric combinations of keywords. However, Google charges you only when a person actually clicks on your ad.
In the field of marketing, the effectiveness of an advertising effort is measured by its conversion rate. The conversion rate can be measured in a variety of ways, but generally it is the sales generated by advertising, divided by the number of impressions (times a consumer sees the ad). For AdWords, Google defines a conversion as "when a click on your ad leads directly to user behavior you deem valuable, such as a purchase, signup, page view, or lead." This corresponds to the marketing industry's response to purchase conversion rate: the number of purchases divided by the number of clicks-through. Understanding the conversion rate of a given ad can help you refine your AdWords ad copy and decide if the campaign is bringing the return on investment you expect.
Google provides a mechanism to help you tally purchases that come from customers clicking AdWords ads. This mechanism is triggered by a small piece of code you place in your transaction processing system. This hack shows how to enable a Google AdWords ad in your PayPal eCommerce system and track sales from that ad's referrals. The system consists of three parts:
A tracking-enabled Google AdWords placement
A PayPal-enabled selling page
An IPN page with the Conversion Tracking Code
You need to have one or more Google AdWord placements that refer people to your PayPal selling page. You can have as many ad placements as you like.
Log into the Google AdWord system (http://adwords.google.com), go to your campaign summary, and click the Conversion Tracking tab to display the screen in Figure 7-2.
You will see an option to select Basic Tracking or Customized Tracking; select the Customized Tracking option. Select the Purchase/Sale option from the tracking options, which brings you to a page that has a generated a snippet of tracking code. Copy and paste the code into a text editor. It should look something like this:
You'll place this code in your IPN processing page. But first, copy the Google conversion ID from this code (on the fourth line, in this example) for use in your AdWord placement. Use the Edit function from the Ad Group detail page to change the Destination URL. This URL is not displayed to the visitor, but when the ad is clicked, this is the URL to which visitors are sent. Visitors are directed to the PayPal-enabled sales page named widget.asp, and the URL includes a parameter, convid, set to the value of your Google conversion ID:
<input type="hidden" name="custom" value="<%=Request.QueryString("convid")%>">
Now, the PayPal button is able to pass on the Google conversion ID to PayPal. When the transaction is processed, PayPal sends the conversion ID on to your IPN processing page.
The IPN page finishes the job of tracking conversions. Take the code you copied from Google in the preceding section and paste it into your IPN page after the standard IPN processing chores (the section that begins with process payment in PayPal's example scripts). Since the code is meant for client-side interpretation, you need to temporarily interrupt the server-side code processing by escaping the processor and adding your script. In ASP, stop the server-side processing with a %> tag and start it again with a <% tag:
When an order is placed at your web site from a Google AdWord referral, the Google Conversion tracking system is activated. You can log into your Google AdWords account and evaluate your campaign's effectiveness in Google's conversion tracking system, as shown in Figure 7-3.
For practical ways to calculate and use conversion rates in your marketing campaigns, see Strategic Database Marketing : The Master Plan for Starting and Managing a Profitable, Customer-Based Marketing Program by Arthur M. Hughes (McGraw-Hill).
For the nitty-gritty details on AdWords and conversion tracking, see Chapter 9, "Making Money with Google," of Google: The Missing Manual by Sarah Milstein and Rael Dornfest (O'Reilly).