English | Site Directory

Google Checkout APIs

Using Google Analytics to Track Google Checkout Orders

Using Google Analytics to Track Buyers who use Google Checkout
About this Document
Enabling E-Commerce Reporting for Google Analytics
Tracking Google Checkout Orders
Using Analytics with Digitally Signed Checkout XML API Requests
Using Analytics with Server-to-Server Checkout API Requests
Appendixes

Using Google Analytics to Track Buyers who use Google Checkout

Google Analytics enables you to understand how visitors interact with your website. Google Analytics also helps you to identify navigational components that promote or inhibit conversions to sales, enabling you to optimize ad campaigns and website content for increased sales.

As a Google Checkout merchant, you can use Google Analytics to track buyers who leave your site to complete an order using Google Checkout.

About this Document

This document contains the following sections:

  • The Enabling E-Commerce Reporting for Google Analytics section explains how to enable your Google Analytics account to support e-commerce reporting for your site.

  • The Tracking Google Checkout Orders section identifies the different Google Checkout pages for which tracking data is available. It also provides a brief overview of the order information that you can track using Google Analytics and explains how the fields in a Checkout API request map to the fields in Google Analytics reports.

  • The rest of the body of the document is divided into two sections that explain the modifications that you need to make to your Google Analytics tracking code so that you can also track customers who use Google Checkout. Each section includes two sets of instructions that correspond to different releases of Google Analytics. Please follow the instructions that correspond to the method you use to post Checkout API requests and to the Google Analytics JavaScript file called on your page.

    • Digitally Signed Checkout XML API Requests

      When you submit digitally signed Checkout XML API requests, a form on your web page displays a Google Checkout button and also contains an encoded version of the customer's shopping cart. When the user clicks the Google Checkout button, the form posts the encoded shopping cart data directly to Google Checkout.

    • Server-to-Server Checkout XML API Requests

      When you submit server-to-server Checkout API requests, the form on your web page that displays the Google Checkout button submits to another URL on your website. That URL hosts an application that creates a Checkout API request, executes a server-to-server POST request and captures Google's response to that request. The response contains the Google Checkout URL to which the customer should be redirected.

  • Appendix A shows screenshots of the Google Checkout pages for which Google Analytics data is available.

Note: If you do not already have a Google Analytics account, sign up now or learn more about Google Analytics. Also, you can rely on the reports in Google Analytics for general e-commerce trending metrics for your site. However, you should not rely on Google Analytics reports for accounting purposes. Any formal reconciliation of orders placed through Google Checkout should be done using the Reconciliation Report available through the Google Checkout Merchant Center interface.

Enabling E-Commerce Reporting for Google Analytics

To track Google Checkout orders, you must enable e-commerce reporting for your website in your Google Analytics account. The following steps explain how you enable e-commerce reporting for your website:

  1. Log in to your Google Analytics account.

  2. Click the Edit link next to the profile you want to enable. This link appears in the Settings column.

  3. On the Profile Settings page, click the Edit link in the Main Website Profile Information box.

  4. Change the selected E-Commerce Website radio button from No to Yes.

Tracking Google Checkout Orders

This section identifies the Google Checkout pages for which tracking data is available. It also explains the order information that is available in a Google Analytics report and explains how the item information in the Analytics report maps to elements in a Checkout API request.

Pages Tracked in Analytics Reports

Google Analytics data is available for the following Google Checkout pages. Appendix A - Google Checkout Page Screenshots displays screenshots of each of the different pages.

  • The Login page (/login.html) is the first page to appear after the buyer clicks the Google Checkout button. This page displays the items in the buyer's order and lets the buyer sign in to an existing Google account or create a new Google account.

  • The Place Order page (/placeOrder.html) appears after the buyer logs in to Google Checkout. This page displays the items in the buyer's order and also lets the buyer select a shipping method, shipping address and payment option.

  • The Order Confirmed page (/purchaseComplete.html) appears after the buyer places the order. The page displays a link back to your store and messaging about the buyer's order.

Note: Data for each of these pages is reported separately in Google Analytics reports.

Order Information in Analytics Reports

Google Analytics tracks the following information for each Google Checkout order.

  • Order Information - This information is tracked for each order. Please note that the Order Information fields are only reported for the Order Confirmed page.

    • order-id - This value is the unique number that Google assigns to the order. This value does not appear in a Checkout API request.

    • affiliation - This value is left blank in Analytics reports for Google Checkout pages.

    • total - This value is the total cost of the order.

    • tax - This value is the total tax amount charged for the order.

    • shipping - This value is the total shipping amount charged for the order.

    • city - This value identifies the city of the order's shipping address.

    • state/region - This value identifies the state or region of the order's shipping address.

    • country - This value identifies the country of the order's shipping address.

  • Item Information - This information is tracked for each item in the order.

    • order-id - This value is the unique number that Google assigns to the order. This value does not appear in a Checkout API request.

    • sku/code - This value is left blank in Google Analytics reports.

    • product name - This value contains the <item-name> provided for the item in the Checkout API request.

    • category - This value is left blank in Analytics reports for Google Checkout pages.

    • price - This value is the per-unit price for the item. It contains the <unit-price> provided for the item in the Checkout API request.

    • quantity - This value identifies the number of units of a particular item that is included in the order. The value contains the <quantity> provided for the item in the Checkout API request.

Using Analytics with Digitally Signed Checkout XML API Requests

The following subsections explain the changes you need to make to your web pages to track shoppers who complete orders using Google Checkout. These instructions are relevant for merchants who submit digitally signed Checkout XML API requests. If you submit server-to-server API requests, please proceed to the next section.

Please follow the instructions that correspond to the Google Analytics JavaScript file included on your pages:

ga.js
urchin.js

ga.js

The following instructions explain how to integrate the ga.js Google Analytics file with digitally signed orders:

  1. Add the following Google Analytics tracking code to each page on your site that you wish to track. You must modify this code sample to specify your Google Analytics account number in place of the value "UA-XXXXX-X". If you previously signed up for a Google Analytics account, you may have already inserted this code on your pages.

    
    <script type="text/javascript">
      var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
      document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3Cscript%3E"));
    </script>
    
    <script type="text/javascript">
      var pageTracker = _gat._getTracker("UA-XXXXX-X");
      pageTracker._initData();
      pageTracker._trackPageview();
    </script>
    
    

    Note: Your page should include this tracking code as well as the JavaScript code in step 2 before it displays any Google Checkout buttons. This process is different than that described for urchin.js, which requires Checkout buttons to be displayed before the page includes the Analytics tracking code. As such, if you are updating your site to use ga.js rather than urchin.js, you must move the tracking code so that it is called before Google Checkout buttons are displayed.

  2. Add the following JavaScript call to each page that displays a Google Checkout button. This call should appear immediately below the tracking code from step 1.

    <script src="http://checkout.google.com/files/digital/ga_post.js"
      type="text/javascript">
    </script>
    
  3. Add the following hidden input field to each form on your site that displays a Google Checkout button.The value attribute must be specified exactly as shown in the example.

    <input type="hidden" name="analyticsdata" value="">
    
  4. For each form that displays a Google Checkout button, add an onsubmit attribute to the <form> element. The onsubmit element should call the setUrchinInputCode JavaScript function as shown in the following example.

    <form action="..." method="POST" onsubmit="setUrchinInputCode(pageTracker);">
    

    Note: If you are updating your site to use ga.js instead of urchin.js, please note that you must pass the pageTracker object to the setUrchinInputCode function.

Sample Integration using Digitally Signed Carts with ga.js

The example below shows the code necessary to integrate Google Analytics with a Google Checkout implementation. The form in the example represents any form that displays a Google Checkout button. Please note that the values for the cart and signature hidden input fields, which are different for each Checkout API request, have been replaced with ellipses (...) in the example. In addition, you must modify this code sample to specify your Google Analytics account number in place of the value "UA-XXXXX-X". You must also modify the parameter values in the Google Checkout button URL so that the URL specifies your merchant ID.



<script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3Cscript%3E"));
</script>

<script type="text/javascript">
  var pageTracker = _gat._getTracker("UA-XXXXX-X");
  pageTracker._initData();
  pageTracker._trackPageview();
</script>

<script src="http://checkout.google.com/files/digital/ga_post.js"
  type="text/javascript">
</script>


<form action="..." method="POST" onsubmit="setUrchinInputCode(pageTracker);">
    <input type="hidden" name="cart" value="...">
    <input type="hidden" name="signature" value="...">
    <input type="hidden" name="analyticsdata" value="">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="http://checkout.google.com/buttons/checkout.gif?merchant_id=YOUR_MERCHANT_ID
        &w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/>
</form>

urchin.js

  1. Add the following Google Analytics tracking code to each page on your site that you wish to track. You must modify the value of the _uacct variable in the tracking code to specify your Google Analytics account number in place of the value "UA-XXXXX-X". If you previously signed up for a Google Analytics account, you may have already inserted this code on your pages.

    
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
        _uacct = "UA-XXXXX-X";
        urchinTracker();
    </script>
    
    

    Note: Your page should display all of the forms that contain Google Checkout buttons before including this tracking code. As such, we recommend that you include the call near the bottom of your page.

  2. Add the following JavaScript call to each page that displays a Google Checkout button. This call should appear immediately below the tracking code from step 1.

    <script src="http://checkout.google.com/files/digital/urchin_post.js"
      type="text/javascript">
    </script>
    
  3. Add the following hidden input field to each form on your site that displays a Google Checkout button. The value attribute must be specified exactly as shown in the example.

    <input type="hidden" name="analyticsdata" value="">
    
  4. For each form that displays a Google Checkout button, add an onsubmit attribute to the <form> element. The onsubmit element should call the setUrchinInputCode JavaScript function as shown in the following example.

    <form action="..." method="POST" onsubmit="setUrchinInputCode();">
    

Sample Integration using Digitally Signed Carts with urchin.js

The example below shows the code necessary to integrate Google Analytics with a Google Checkout implementation. The form in the example represents any form that displays a Google Checkout button. Please note that the values for the cart and signature hidden input fields, which are different for each Checkout API request, have been replaced with ellipses (...) in the example. In addition, you must modify the value of the _uacct variable in the tracking code to specify your Google Analytics account number in place of the value "UA-XXXXX-X". You must also modify the parameter values in the Google Checkout button URL so that the URL specifies your merchant ID.


<form action="..." method="POST" onsubmit="setUrchinInputCode();">
    <input type="hidden" name="cart" value="...">
    <input type="hidden" name="signature" value="...">
    <input type="hidden" name="analyticsdata" value="">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="http://checkout.google.com/buttons/checkout.gif?merchant_id=YOUR_MERCHANT_ID
        &w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/>
</form>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
    _uacct = "UA-XXXXX-X";
    urchinTracker();
</script>

<script src="http://checkout.google.com/files/digital/urchin_post.js"
  type="text/javascript">
</script>


Using Analytics with Server-to-Server Checkout API Requests

The following subsections explain the changes you need to make to your web pages to track shoppers who complete orders using Google Checkout. These instructions are relevant for merchants who submit server-to-server Checkout API requests.

Please follow the instructions that correspond to the Google Analytics JavaScript file included on your pages:

ga.js
urchin.js

ga.js

  1. Follow the instructions for integrating the Google Analytics ga.js file with a digitally signed shopping cart.

  2. Modify the form handler on your site that executes when a user clicks a Google Checkout button. The form handler needs to extract the value of the analyticsdata field so that the value can be included in the Checkout API request.

  3. Add the <analytics-data> element to your Checkout API requests. The element's value should be the analyticsdata field captured in the previous step. The <analytics-data> element is a subtag of the <merchant-checkout-flow-support> element.

Sample Integration using Server-to-Server Requests with ga.js

The example below is divided into two parts.

  1. The first part shows the code changes necessary to integrate Google Analytics with a Google Checkout implementation. The form in the example represents any form on your page that displays a Google Checkout button. Please note that you must modify this code sample to specify your Google Analytics account number in place of the value "UA-XXXXX-X" You must also modify the parameter values in the Google Checkout button URL so that the URL specifies your merchant ID.

  2. The second part of the example shows an excerpt from a Checkout API request that includes the <analytics-data> element. Please note that this element's value will differ for each Checkout API request.

Part I: Integrating Google Analytics into your checkout page



<script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3Cscript%3E"));
</script>

<script type="text/javascript">
  var pageTracker = _gat._getTracker("UA-XXXXX-X");
  pageTracker._initData();
  pageTracker._trackPageview();
</script>

<script src="http://checkout.google.com/files/digital/ga_post.js"
  type="text/javascript">
</script>


<form action="..." method="POST" onsubmit="setUrchinInputCode(pageTracker);">
    <input type="hidden" name="analyticsdata" value="">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="http://checkout.google.com/buttons/checkout.gif?merchant_id=YOUR_MERCHANT_ID
        &w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/>
</form>

Part II: Integrating Google Analytics into your Checkout API request

After extracting the value of the analyticsdata field, your form handler will send the Checkout API request to Google, including the <analytics-data> element in the request:


<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
    <shopping-cart>
        <items>
            ...
        </items>
    </shopping-cart>
    <checkout-flow-support>
        <merchant-checkout-flow-support>
            <shipping-methods>
                ...
            </shipping-methods>
            <analytics-data>SW5zZXJ0IDxhbmFseXRpY3MtZGF0YT4gdmFsdWUgaGVyZS4=</analytics-data>
        </merchant-checkout-flow-support>
    </checkout-flow-support>
</checkout-shopping-cart>

urchin.js

  1. Follow the instructions for integrating the Google Analytics urchin.js file with a digitally signed shopping cart.

  2. Modify the form handler on your site that executes when a user clicks a Google Checkout button. The form handler needs to extract the value of the analyticsdata field so that the value can be included in the Checkout API request.

  3. Add the <analytics-data> element to your Checkout API requests. The element's value should be the analyticsdata field captured in the previous step. The <analytics-data> element is a subtag of the <merchant-checkout-flow-support> element.

Sample Integration using Server-to-Server Requests with urchin.js

The example below is divided into two parts.

  1. The first part shows the code changes necessary to integrate Google Analytics with a Google Checkout implementation. The form in the example represents any form on your page that displays a Google Checkout button. Please note that you must modify the value of the _uacct variable in the tracking code to specify your Google Analytics account number in place of the value "UA-XXXXX-X". You must also modify the parameter values in the Google Checkout button URL so that the URL specifies your merchant ID.

  2. The second part of the example shows an excerpt from a Checkout API request that includes the <analytics-data> element. Please note that this element's value will differ for each Checkout API request.

Part I: Integrating Google Analytics into your checkout page


<form action="..." method="POST" onsubmit="setUrchinInputCode();">
    <input type="hidden" name="analyticsdata" value="">
    <input type="image" name="Google Checkout" alt="Fast checkout through Google"
        src="http://checkout.google.com/buttons/checkout.gif?merchant_id=YOUR_MERCHANT_ID
        &w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/>
</form>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
    _uacct = "UA-XXXXX-X";
    urchinTracker();
</script>

<script src="http://checkout.google.com/files/digital/urchin_post.js"
  type="text/javascript">
</script>


Part II: Integrating Google Analytics into your Checkout API request

After extracting the value of the analyticsdata field, your form handler will send the Checkout API request to Google, including the <analytics-data> element in the request:


<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">
    <shopping-cart>
        <items>
            ...
        </items>
    </shopping-cart>
    <checkout-flow-support>
        <merchant-checkout-flow-support>
            <shipping-methods>
                ...
            </shipping-methods>
            <analytics-data>SW5zZXJ0IDxhbmFseXRpY3MtZGF0YT4gdmFsdWUgaGVyZS4=</analytics-data>
        </merchant-checkout-flow-support>
    </checkout-flow-support>
</checkout-shopping-cart>

Appendixes

Appendix A - Google Checkout Page Screenshots

Google Analytics data is available for the following Google Checkout pages.

  • The Login page (/login.html) is the first page to appear after the buyer clicks the Google Checkout button. This page displays the items in the buyer's order and lets the buyer sign in to an existing Google account or create a new Google account.

    Login page (/login.html)

  • The Place Order page (/placeOrder.html) appears after the buyer logs in to Google Checkout. This page displays the items in the buyer's order and also lets the buyer select a shipping method, shipping address and payment option.

    Place Order page (/placeOrder.html)

  • The Order Confirmed page (/purchaseComplete.html) appears after the buyer places the order. The page displays a link back to your store and messaging about the buyer's order.

    Order Confirmation page (/purchaseComplete.html)

Note: Data for each of these pages is reported separately in Google Analytics reports.