Track transaction-specific conversion values

30/11/2019

When you track customer actions that might have different values each time they occur, such as purchases of items with different prices, you can provide transaction-specific values for each conversion. This helps you have a more accurate sense of your return on investment (ROI).

When setting up a new website or in-app conversion action, you can assign the same conversion value to all conversions (sometimes referred to as "static" values), or different values to reflect transaction-specific (or "dynamic") values. The following information only applies to transaction-specific values.

In the sections below, we'll show you how to edit your conversion tracking tag to support transaction-specific values for your website technology or mobile app platform.

Before you begin


Here's what you'll need before you can set up conversion tracking for transaction-specific values on your website:

  • An Google Ads account: Don't have one yet? Sign up at https://ads.google.com.
  • Google Ads conversion tracking setup: You must have at least one conversion action to track transaction-specific values. If you haven't done so yet, follow the instructions to create a conversion action and get the tag.
  • A website: This is where you'll put the conversion tracking code (called a "tag").
  • Ability to edit website code: Either you or your or webmaster will need to be able to modify your website.

Instructions

The new Google Ads experience is now the exclusive way for most users to manage their accounts. If you’re still using the previous AdWords experience, choose “previous” below. Learn more

How to track transaction-specific values on a website

Part 1: Requirements

Here's what you'll need before you can set up conversion tracking for transaction-specific values on your website:

  • An AdWords account: Don't have one yet? Sign up at https://adwords.google.com.
  • AdWords conversion tracking setup: You must have at least one conversion action to track transaction-specific values. If you haven't done so yet, follow the instructions to create a conversion action and get the tag.
  • A website: This is where you'll put the conversion tracking code (called a "tag").
  • Ability to edit website code: Either you or your or webmaster will need to be able to modify your website.

Part 2: Set up transaction-specific conversion tracking in your AdWords account

First, you'll need to make sure you selected "The value of this conversion action may vary" during the conversion setup process. If not, or you need to check, follow these steps:

  1. Sign in to your AdWords account.
  2. Click the Tools tab, and select Conversions from the drop-down menu.
  3. Click the name of the conversion action you want to edit.
  4. Click the Edit conversion settings button.
  5. Click Value. Select "The value of this conversion action may vary." Provide a backup value to use when one isn't provided. Click Done.
  6. Click Save.
  7. Select one of the two options under "Install your tag."
    • Save instructions and tag: Select this option if you'll be installing the conversion tracking tag on your website yourself.
    • Email instructions and tag: Select this option if someone else, such as your webmaster, will be installing the tag on your website.
  8. Click Done.

Part 3: Add or modify the tag in your website's code

Next, add or modify the tag in your website's code. No matter which technology you use, make sure the page you put the code snippet on is the one your customer sees after a conversion.

When inserting the tag, you'll place it on the static portion of the page, found within the section. See the sections below for detailed instructions on modifying the conversion tag to support transaction-specific values for specific technologies used to generate your webpages:

Active Server Pages (ASP)

If you'd like to add conversion tracking code to ASP pages using your ASP editor, look to the code below, then remove from your own code the lines that are crossed out, and manually add the areas that are highlighted. If you're tracking button or link clicks as conversions instead of page loads, the changes to your code will be slightly different. See these instructions for tracking clicks as conversions for more information.

	
	...
	
	
	
	
	
	

If your web server supports Server Side Includes (SSI) you can use an #include statement to insert the conversion tracking code onto your site. After you generate your conversion code snippet, save it to a file on your web server -- we recommend using the filename googleconversion.html.

Search for the tag and place the #include statement with the location of the file directly above it. If the tag is not located within the static portion of the HTML page, add the code snippet so it appears within the body section of the page.

	
	Thank You for Shopping
	
	
	...
	
	
		

Keep in mind

Be sure that you do not place the #include statement in the footer or header of the file. This will cause Google to record a conversion every time a customer visits any page on your site.

The #include statement will be evaluated before the rest of the of the ASP pages so you're able to use an ASP expression as the dynamic value of the conversion.

  1. Open your conversion confirmation page ASP file. If multiple pages are generated from the same file, find the section in the ASP file that generates your conversion page.
  2. If your site has a variable conversion value, determine the ASP expression which calculates that value. For example: <%= totalValue %>.
  3. Choose the "Purchase/Sale" conversion category while going through the conversion tracking setup.
  4. Enter a default numeric value in the "Conversion value" field, then replace the line "var google_conversion_value = …" manually with the following:
    	if (<%= totalValue %) {
    	var google_conversion_value = <%= totalValue %>;
    	}
    				
    You'll also need to replace the default numeric value with "<%= totalValue%>" in the
  5. (Optional) If you accept different currencies, add a line within the if statement to accept currency: var google_conversion_currency = <%= currency %>;

    In the noscript section of the tag, be sure to add ¤cy_code=<%= currency %>
  6. Copy and save the resulting code snippet.
  7. Insert the conversion tracking code onto the conversion confirmation page. Make sure that the code appears within a static HTML section, not contained within an ASP code section (delineated by <%= and %> markers).
  8. Insert the conversion tracking code directly into the body of the conversion confirmation page. Search for the tag and place the code immediately above it. If the tag isn't located within the static portion of the HTML page, make sure the code snippet is added so it appears within the body section of the page.
  9. Save your conversion confirmation file and upload it to your web server, if necessary. If you'd like to test the placement of your conversion tracking code, visit your conversion page by completing a conversion on your site.
  10. In your web browser, view the source of the webpage (in most browsers, right-click on the page and select View source). You should see the conversion tracking code between the and tags on your page. The ASP expression will be replaced by the actual conversion value when you view the source.

Sun® Java Server Pages (JSP)

To add conversion tracking code to JSP pages using your JSP editor, look to the code below, then remove from your own code the lines that are crossed out, and manually add the areas that are highlighted. If you're tracking button or link clicks as conversions instead of page loads, the changes to your code will be slightly different. See these instructions for tracking clicks as conversions for more information.

		
	
	
	
	
	
		

You can also insert the conversion tracking code onto your site using a server-side jsp:include statement. After you generate your conversion code snippet, save it to a file on your web server - we recommend using the filename googleconversion.html. Search for the tag and place the jsp:include statement with the location of the file directly above it. If the tag isn't located within the static portion of the HTML page, make sure that you add the code snippet so that it appears within the section of the page.

		
	
	
	Thank You for Shopping
	
	
	...
	
	
	
		

Keep in mind

Be sure you don't place the jsp:include statement in the footer or header of the file, as is sometimes common. This will cause Google to record a conversion every time a customer visits any page on your site.

The jsp:include statement will be evaluated before the rest of the of the JSP pages so you're able to use a JSP expression as the dynamic value of the conversion.

If your web server supports Server Side Includes (SSI) you can use an #include statement to insert the conversion tracking code onto your site. After you generate your conversion code snippet, save it to a file on your web server. We recommend using the filename googleconversion.html. Search for the tag and place the #include statement with the location of the file directly above it. If the tag isn't located within the static portion of the HTML page, make sure that you add the code snippet so that it appears within the section of the page.

		
	
	Thank You for Shopping
	
	
	...
	#include file=".../googleconversion.html"
	
		

The #include statement will be evaluated before the rest of the of the JSP pages so you're able to use a JSP expression as the dynamic value of the conversion.

Keep in mind

Be sure you do not place the #include statement in the footer or header of the file, as is sometimes common. This will cause Google to record a conversion every time a customer visits any page on your site.

  1. Open your conversion confirmation page JSP file. If multiple pages are generated from the same file, find the section in the JSP file which generates your conversion page.
  2. If your site has a variable conversion value, determine the JSP expression which calculates that value. For example: <%= totalValue %>, ${totalValue}
  3. Choose the "Purchase/Sale" conversion category while going through the conversion tracking setup.
  4. Enter a default numeric value in the "Conversion value" field, then replace the line var google_conversion_value = … manually with the following:
    	if (<%= totalValue %) {
    		var google_conversion_value = <%= totalValue %>;
    	}
    				
    You'll also need to add replace the default numeric value with <%= totalValue%> in the
  5. (Optional) If you accept different currencies, add a line within the if statement to accept currency: var google_conversion_currency = <%= currency %>;

    In the noscript section of the tag, be sure to add ¤cy_code=<%= currency %>
  6. Copy and save the resulting code snippet.
  7. Insert the conversion tracking code snippet onto the conversion confirmation page. Make sure that the code appears within a static HTML section, not contained within an JSP code section (delineated by <%@ and %> markers).
  8. Insert the conversion tracking code directly into the body of the conversion confirmation page. Search for the tag and place the code immediately above it. If the tag isn't located within the static portion of the HTML page, be sure you add the code snippet so within the body section of the page.
  9. Save your conversion confirmation file and upload to your web server if necessary. If you'd like to test the placement of your conversion tracking code, go to your conversion page by completing a conversion on your site. In your web browser, view the source of the webpage (in most browsers, right-click on the page and select View source). You should see the conversion tracking code between the and tags on your page. The JSP expression will be replaced by the actual conversion value when you view the source.

PHP: Hypertext Preprocessor (PHP)

To add conversion tracking code to PHP pages using your web page editor, look to the code below, then remove from your own code the lines that are crossed out, and manually add the areas that are highlighted. If you're tracking button or link clicks as conversions instead of page loads, the changes to your code will be slightly different. See these instructions for tracking clicks as conversions for more information.

		
	
	
	
	
	
		
  1. Open your conversion confirmation page PHP file. If multiple pages are generated from the same file, find the section in the PHP file which generates your conversion page.
  2. If your site has a variable conversion value, determine the PHP expression that displays that value. For example: ,
  3. Choose the "Purchase/Sale" conversion category while going through the conversion tracking setup.
  4. Enter a default numeric value in the "Conversion value" field, then replace the line var google_conversion_value = … manually with the following:
    	if () {
    		var google_conversion_value = ;;
    	}
    You'll also need to add replace the default numeric value with <%= totalValue%> in the
  5. (Optional) If you accept different currencies, add a line within the if statement to accept currency: var google_conversion_currency =

    In the noscript section of the tag, be sure to add ¤cy_code=
  6. Copy and save the resulting code snippet.
  7. Insert the conversion tracking code onto the conversion confirmation page. Make sure that the code appears within a static HTML section, not contained within an PHP code section (delineated by and ?> markers). As you insert the code snippet, make sure you place it directly into the body of the conversion confirmation page. To make sure you do, search for the tag and place the code immediately above it. Or, if the tag isn't located within the static portion of the HTML page, make sure that you add the code snippet so that it appears within the section of the page as shown below.
  8. Save your conversion confirmation file and upload to your web server if necessary. If you'd like to test the placement of your conversion tracking code, go to your conversion page by completing a conversion on your site. In your web browser, view the source of the webpage (in most browsers, right-click on the page and select View source). You should see the conversion tracking code between the and tags on your page. The PHP expression will be replaced by the actual conversion value when you view the source.

Webpages containing frames

In cases where frames are used, it's best to insert the code snippet only within the HTML of the frame containing the conversion page.

Secure and non-secure pages

The code snippet can be used safely on both secure (https://) and non-secure (http://) pages.

 

Security and privacy for website tracking

Google's security standards are strict. Only pages containing the Google conversion tag are tracked through this program. We use data encryption and secure servers.

Please ensure you're providing users with clear and comprehensive information about the data you collect on your websites, and getting consent for that collection where legally required.

* Nguồn: Google