Conversion tracking guide for Ad Grants and PayPal

How to track transaction-specific conversions with PayPal donations

In order to track Donations with PayPal, both the payment details and the customer need to be sent back to [www.your-site.com] once the transaction is completed on PayPal.com.

The conversion tracking code can then be executed with the relevant payment details being used as values.

To accomplish this, the following steps need to be followed. 

Before you begin

Make sure you have the following before proceeding to setup conversions in Google Ads with PayPal.

This article is intended for use after global site tag implementation. If you still need to implement the global site tag on your website, read Use the global site tag for Google Ads conversion tracking

Step 1A: Changing Your Website Conversion Tracking using Google Ads

To use Google Ads Conversion Tracking with PayPal on your website, you will need to put a small snippet of HTML code on the page that customers see after they've completed a valuable action on their site. For example, you could add the code to your purchase confirmation page. This is the same process for both Mobile and Desktop Websites.

Steps to set up a website conversion for PayPal

  1. Ensure the specific account has a properly functioning website that is able to be edited with the conversion tracking tag.

  2. Sign in to your Google Ads account.

  3. In the upper right corner, click the Tools icon , and under "Measurement," click "Conversions.

  4. Click the plus button .

  5. Click Website.

  6. Next to “Conversion name,” enter a name for the conversion you’d like to track, such as “newsletter sign up” or “wedding bouquet purchase.” This will help you recognize this conversion action later in conversion reports.

  7. Next to “Category,” select a description for your conversion action from the drop-down. The category allows you to segment your conversions in reports, so you can see similar conversions together.

    1. Use “Purchase” in order to track donations on your donation page.

  8. Next to “Value,” select how to track the value of each conversion.

    1. Use different values for each conversion. Use this option if, for example, you’re tracking purchases of products with different prices. Later, when you add your conversion tracking tag, you’ll need to customize your tag to track transaction-specific values

  9. Next to “Count,” select how to count these conversions.

    1. Every. This setting is best for sales, when every conversion likely adds value for your business.

  10. Click Conversion window. Select how long to track conversions after an ad interaction from the drop-down. The window can be 1 to 90 days. Learn more about conversion windows.

  11. Click View-through conversion window. Select how long to track view-through conversions from the drop-down. The window can 1 to 30 days.

  12. Click Include in “Conversions.” This setting—selected by default—lets you decide whether or not to include data for this conversion action in your "Conversions" reporting column. If you uncheck this setting, data will still be included in the "All conversions" column. You might want to uncheck this setting if you use Smart Bidding, and you don't want to include this particular conversion action in your bid strategy. Learn more about the "Include in 'Conversions'" setting.

  13.  Click Create and continue.

  14. Move on to Tag Setup and "Install the tag yourself" to see the code. As a reminder, you'll need to add 2 code snippets to your website: the global site tag and the event snippet. If you've already implemented the global site tag on all pages, choose "The global site tag on all pages was installed already when you created another conversion action in this Google Ads account."

  15. Next to "Event snippet," select whether to track conversions on a page load or click. Choose Page load so you're able to count conversions when customers visit the conversion page, such as a confirmation page for a purchase or sign-up. This is the default and most common option.

  16. Copy the snippet and paste it in between the <head></head> tags of the page(s) you'd like to track, right after the global site tag.

Example of finished code, with the added value, currency, and transaction_id:

<!-- Event snippet for Paypal Donation -dynamic conversion values conversion page -->
<script>
  gtag('event', 'conversion', {
      'send_to': 'AW-1234567890/ZZZ123ZZZ123ZZZ123_Z1',
      'value': '',
      'currency': '',
      'transaction_id': ''
  });
</script>
<!-- End Event snippet for Paypal Donation -dynamic conversion values conversion page -->    

Step 1B: Changing Your Website Conversion Tracking using Google Analytics Goals

In order to track E-Commerce transactions, both the payment details and the customer need to be sent back to [www.your-site.com] once the transaction is completed on PayPal.com. The Google Analytics E-Commerce tracking code can then be executed with the relevant payment details being used as values. In order to accomplish this, the following Steps need to be followed.

These steps assume you've already implemented Analytics Ecommerce Tracking. If you haven't yet done so, read: Set up Ecommerce Tracking.

Steps to edit your Analytics E-Commerce Tracking Code

Although the asynchronous Google Analytics Tracking Code should not be implemented on the hidden webpage, it should be implemented on the confirmation webpage along with the Google Analytics E-Commerce tracking code. This will allow your business to identify the number of transactions completed along with each transaction’s details. Please complete the following sub-steps to accomplish this implementation.

  1. Implement the same asynchronous tracking code used throughout [www.your-site.com] on the confirmation webpage before the closing </head> tag (shown below). 

  2. Implement a Custom Variable for each additional piece of information that would like to be collected, which the Google Analytics E-Commerce tracking does not collect by default. Each Custom Variable should be set before the _trackPageview method within the asynchronous GATC implemented from Step 5A. An example of how to set a Custom Variables is shown in the code below (highlighted in bold).

  3. Implement the Google Analytics E-Commerce tracking code within the same code snippet as the asynchronous GATC.

Full code example is shown below:

<script type="text/javascript">

 

var _gaq = _gaq || [];

_gaq.push(

['_setAccount', 'UA-xxxxxxx-1'],

['_setDomainName', '.your-site.com'],

['_setCustomVar', 1, 'Course', 'Computer Programming', 3],    

['_trackPageview'],

 

['_addTrans',

'1234', // order ID - required

'School of Technology', // affiliation or store name

'99.99', // total - required

'1.00', // tax

'5', // shipping

'Mountain View', // city

'California', // state or province

'USA' // country

],



 

// add item might be called for every item in the shopping cart

// where your ecommerce engine loops through each item in the cart

// and prints out _addItem for each

 

['_addItem',

'1234', // order ID - required

'DD44', // SKU/code - required

'Programming Techniques', // product name

'Computer Programmer', // category or variation

'51.99', // unit price - required

'1' // quantity - required

],



 

['_trackTrans'] //submits transaction to the Analytics servers

 

);

 

(function () {

var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

var s = document.getElementsByTagName('script')[0];

s.parentNode.insertBefore(ga, s);

 

})();



 

</script>

Steps to enable Ecommerce

After implementation, we’ll need to be sure to enable the Ecommerce feature in your analytics account. To do that:

 

  • In the VIEW column, click Ecommerce Settings.

 

  • Set Enable Ecommerce to ON. [There is no need to enable “Enhanced eCommerce.]

  • Click Next step.

  • Click Submit.

For more details on this feature, please find help here.

Step 2B: Enable Payment Data Transfer (PDT)

By enabling the Payment Data Transfer (PDT) within your PayPal account, will allow the secure transfer of payment details such as the item purchased, the transaction amount and the geographical location of the buyer, to your website. In order to successfully retrieve the payment details, [www.your-site.com] must send a PDT identity token to the PayPal domain. To enable PDT and retrieve the appropriate PDT identity token that needs to be sent, please follow these sub-steps:

Steps to set up PDT on PayPal

  1. Log into the relevant PayPal account.

  2. Click the settings icon at the top of your PayPal account page and then click Profile and settings.

  3. Click on My settings and confirm your Account type is either Premier or Business.

  4. Modify your PayPal Profile. Navigate to My selling tools, and click Update next to Website preferences, which takes you to the Website payment preferences page. Enable Auto Return for Website Payments. Then, specify a Return URL and enable Payment Data Transfer. Payment Data Transfer requires the Return URL setting. PayPal displays an Identity Token. 

  5. Copy and save it; add it to the script on your Return URL page. Specify the [www.your-site.com] hidden webpage URL (detailed in Step 4) for the Return URL value, that both the customer and the transaction ID will be sent to once the transaction has been processed by PayPal.

  6. Write a script that parses the URL-encoded key-value pair string sent to your Return URL page and displays transaction details on this page. See the PDT-specific variables for PayPal's PDT keys (variables). There are additional variables that are shared between the IPN and PDT notification services; a comprehensive list can be found in the IPN and PDT variables reference.

  7. To fulfill orders or take other advanced actions that rely on a database, add to your script as needed.

  8. Test your integration using the PayPal sandbox. First, log in to the Sandbox section of the PayPal developer site and setup sandbox accounts. Then log into the PayPal sandbox with a test merchant account and repeat the Website payment preferences setup steps mentioned above in your sandbox account profile. For more information on Sandbox testing, see the Sandbox guide

  9. You're ready to go live once you've verified that your implementation works correctly in the PayPal sandbox.

 

More information on Payment Data Transfer (PDT) is available in PayPal Developer.

Step 3: Create the PayPal Donate Button

A PayPal “Donate” button should be created that will send the customer back to [www.your-site.com].


 

This can be accomplished by completing the following sub-steps: 

  1. Log in to your PayPal Premier or Business account at paypal.com. Your PayPal account Summary page opens.

  2. At the top of the page, select Tools, and then All Tools.

  3. Scroll to the PayPal buttons tile and click Open.

  4. Select the type of button you want to create. In this case, Donation. The Create PayPal payment button page opens and displays the button's configuration options.

  5. Follow the on-screen instructions from the Create PayPal payment button webpage currently displayed to create the button.

  6. Ensure the button directs the customer to the return URL (detailed in Step 4)

More information on Button setup and editing is available in PayPal Developer.

Step 4: Create Return URL Webpage to collect PayPal Payment Data

Its URL should be specified as the Return URL value in Steps 1 and 2. Once all steps below have been carried out, this hidden webpage will be sent the details of each transaction completed on PayPal.com.

A webpage should be created on [www.your-site.com] that is not part of the website’s sitemap e.g. [www.your-site.com]/processtransaction.aspx. Such a webpage is often referred to as a “hidden webpage” within the web development industry. 

Step 5: Retrieve Transaction Details

Once a customer successfully completes the payment process and selects the “Donate” button, this will result in sending the transaction ID via a HTTP GET request method to the hidden webpage as a parameter attached to the Return URL. This parameter will appear on the end of the Return URL e.g. [www.client-site.com]/processtransaction.aspx?tx=transactionID. In order to accomplish flow point 3, 4 and 5 the following sub-steps need to be carried out.

Steps to set up transactions to the hidden webpage

  1. Send FORM - Once the transaction ID is received, a FORM via HTTP POST should be sent to PayPal that includes both the received transaction ID and the identity token noted in Step 1h. The form posted should look similar to the following:    

<form method=post action="https://www.paypal.com/cgi-bin/webscr">

 

<input type="hidden" name="cmd" value="_notify-synch"> 

 

<input type="hidden" name="tx" value="theTransactionID"> 

 

<input type="hidden" name="at" value="theIdentityToken"> 

 

<input type="submit" value="PDT"> 

 

</form>

The first line of PayPal’s response to the FORM will contain either “Success” or “Fail” to indicate whether the request was successful. An example of a successful response (without the HTTP Header) would look similar to the following:

SUCCESS 

 

first_name=John 

 

last_name=Doe 

 

payment_status=Completed 

 

payer_email=dee%40google.com 

 

payment_gross=1249.99 

 

mc_currency=USD 

 

custom=Computer+Programming

Please review the list of all possible PDT variables and values that PayPal can return and make use of those in the FORM that will be beneficial for the business to retrieve.

 
  1. Store and Send Transaction Details - The transaction details that will be received from PayPal.com need to be stored and sent by the hidden webpage onto a “confirmation” webpage (detailed in the next sub-step). A query string, cookies or post variables could be used to send the details to the confirmation webpage. It is recommended to use a JavaScript redirect from the hidden webpage to send the customer to the confirmation webpage. Just in case the hidden webpage is seen by the customer it is recommended to display text such as “Transaction processing...” to provide details on the purpose of the hidden webpage. 

  2. Create Confirmation Webpage – This should be the last webpage displayed to the customer in the transaction process e.g. [www.your-site.com]/confirmationpage.aspx. It will confirm that the transaction was successful.

  3. [Optional] If you use Google Analytics for reporting: Append Google Analytics Parameter – The “__utmz” Google Analytics cookie would have been set when the customer visited [www.your-site.com] to begin the application process. This cookie stores campaign/referrer information (the campaign/referring website that brought the customer to [www.client-site.com]). To ensure that this referrer information is not changed due to the customer returning to the website from PayPal.com, a “utm_nooverride=1” Google Analytics parameter should be used. The confirmation webpage URL should contain this parameter when the customer is redirected to it from the hidden webpage e.g. [www.client-site.com]?utm_nooverride=1.

Was this helpful?
How can we improve it?