Overview
Conversion tracking keeps the track of conversions initiated by Google
through one of our Action Center integrations. It's
necessary to keep your integration healthy and running, as it can influence the
ranking on certain pages. Each time Google generates an action_link
, the
specific URL is modified to include a unique query parameter: rwg_token
. You
can store the token and return the appropriate values when a user completes a
booking.
To complete the integration, follow these steps:
- Parse and store the
rwg_token
. - Parse and store the merchant information.
- Return the
rwg_token
and themerchant_changed
values. - Test and verify the conversion tracking.
Parse and Store the rwg_token
To complete the integration you need to collect and store the rwg_token
for up
to 30 days of the initial Google referral. The rwg_token
value is an encoded
string, which contains metadata about the link and the merchant information that
generated that action_link
.
Parse the Token
When a user is directed to your booking page, a new rwg_token
is appended to
the URL provided. In your booking page, you need to parse the token value.
The following example shows how the rwg_token
is parsed for device-level
tracking through a browser.
var query = location.search.substring(1);
var params = query.split('&');
var rwgToken = undefined;
for (var i = 0; i < params.length; ++i) {
var pair = params[i].split('=');
if (pair[0] == 'rwg_token') {
rwgToken = decodeURIComponent(pair[1]);
break;
}
}
The token appended to your URL is encrypted, see the following example of a
rwg_token
. Use this sample token to ensure that you parse the token correctly,
along with any special characters such as =
.
AJKvS9WeONmWKEwjG0--HdpzMq0yAVNL8KMxbb44QtbcxMhSx_NUud5b8PLUBFehAIxOBO-iYRIJOknEFkIJmdsofdVJ6uOweQ==
Store the Token
When you store the rwg_token
, you can implement conversion tracking at two
different levels:
- Device-level
- User-level
You can store the token at any level, but you must store the token for 30 days after the initial referral.
The following example shows the device-level conversion tracking. You can store
the token values in a browser with the first-party cookie. This example assumes
that you parsed the token value into a variable. Make sure to update
rootdomain.com
with your domain.
if (typeof rwg_token !== 'undefined') {
document.cookie =
"_rwg_token=" + rwg_token + ";max-age=2592000;domain=rootdomain.com;path=/";
}
Each time Google generates an action_link
that you have provided through the
feeds, the URL is modified to include a unique query parameter: rwg_token
. You
must store this token, and pass it back as part of the conversion event.
Store at Device-Level
The device-level includes the use of browser cookies, local storage, app local storage, or any other method that can persist the token for the 30 days attribution window. The token is stored locally on the user's device. So, the conversion event can't attribute properly, if the user:
- Changes the device they use.
- Clears the local storage or cookies.
- Uses a private or incognito browser.
When you use the device-level conversion tracking, you need to re-implement the conversion event across every supported device that includes mobile.
Store at User-Level
The user-level persists the token in your application database, through a server-side analytics system or other server-side systems. The token is stored on the server-side. So, the conversion event still attributes properly after the user logs back in.
When you use user-level conversion tracking based on your system architecture, you can implement the conversion event once on your server-side and reuse it across all supported devices.
Refresh the Token
When Google refers a user to the same merchant, the existing token which is already stored, is replaced with the new token from the latest referral. After the token replacement, the 30 days attribution window of the token storage resets and any new conversions for this merchant, attribute to the latest token.
Refer to Requirements for Conversion Attribution for more details.
Parse and Store the Merchant Information
When a user is directed to your booking page, you need to implement the logic
that can find and capture the merchant details. Typically, partners add merchant
metadata or merchant_id
to their action links and use that to identify and
store the merchant information.
We recommend you to store the merchant_id
or the selected identifier along
with the rwg_token
. When a user confirms a booking, you can refer to the
merchant before you send the complete conversion request. Similar to the token
storage, you must save the merchant details with the token for 30 days after
the initial referral.
The following example modifies the previously stored rwg_token
. It assumes
that you parsed the merchant information from metadata in the provided URL and
either saved it as a merchant_id
or matched it to an existing merchant_id
.
if (typeof rwg_token !== 'undefined') {
document.cookie =
"_rwg_token=" + rwg_token + ";_merchant_id=" + merchantid + ";max-age=2592000;domain=rootdomain.com;path=/";
}
Return the rwg_token
and the merchant_changed
Values
When a user completes a booking that begins from an action_link
referral, you
need to send an HTTP POST request to the conversion endpoint. There are two
endpoints:
- Production environment: https://www.google.com/maps/conversion/collect
- Sandbox environment: https://www.google.com/maps/conversion/debug/collect
When you send a conversion event, you must include the stored rwg_token
and a merchant_changed
value of 1
or 2
. For more details on
merchant_changed
, see Return the Merchant Change Value.
The POST body must be a JSON encoded object in the format:
{
"conversion_partner_id": "<partnerId>",
"rwg_token": "<rwg_token_val>",
"merchant_changed": "1|2"
}
{
"conversion_partner_id": "XXXXXXX",
"rwg_token": "AJKvS9WeONmWKEwjG0--HdpzMq0yAVNL8KMxbb44QtbcxMhSx_NUud5b8PLUBFehAIxOBO-iYRIJOknEFkIJmdsofdVJ6uOweQ==",
"merchant_changed": "2"
}
The following example includes device-level conversion tracking with a cookie on the user's device, written in JavaScript:
const partnerId = XXXXXXXXXX;
const endpoint = `https://www.google.com/maps/conversion/collect`;
const rwgTokenCookie = document.cookie
.split('; ')
.find(row => row.startsWith('_rwg_token='));
if (typeof rwgTokenCookie !== 'undefined') {
const rwgTokenVal = rwgTokenCookie.split('=')[1];
fetch(endpoint, {
method: "POST",
body: JSON.stringify({
conversion_partner_id: partnerId,
rwg_token: rwgTokenVal,
merchant_changed: merchantChanged
})
});
}
Return the Merchant Change Value
The merchant_changed
value is used to determine if the merchant is changed
from the initial redirect merchant. Change of merchants is common if your
landing page is within a platform that includes other merchants. In this case,
if a user is referred to your platform by Google and decides to navigate to a
different merchant to complete a booking, you need to know that a conversion
happened with a separate merchant. You can use a Boolean to identify the
merchant change, but not the merchant details.
When you decide which value to assign to the merchant_changed
, you need to take
the original merchant saved in
Parse and Store the Merchant Information. Check if the
merchant has changed, and assign the value as per your requirement.
- Requirement: when a user leaves the original merchant's website and
completes a purchase through your platform with a different merchant.
- Merchant change value:
1
- Merchant change value:
- Requirement: when the user completes a transaction through the original
merchant.
- Merchant change value:
2
- Merchant change value:
Test and Verify the Conversion Tracking
The following test cases use test tokens provided in the
Test Tokens section and are intended to help guide you through
all of various scenarios that can result in a conversion event. This ensure that
the token is stored appropriately, the merchant_changed
value is set
correctly, and the conversion event is sent when appropriate.
Use the action link or booking page URLs provided in your feeds, and run each test case by appending the Test Tokens to the end of the URL. Be sure to use a private or incognito browser window -- this will clear any existing tokens associated with the current user and give you a clean slate to work with.
Test Case | Test Description | User Flow | Expected Outcome |
---|---|---|---|
1 | A user completes a booking that did not originate on Google. | A user navigates directly to the booking page without being referred to by Google or without an existing referral. This shouldn't result in any conversion event. | No conversion event because the user did not previously visit the booking page or was not referred by Google. |
2 | A user completes a booking that originated on Google. | A user finds your merchant through Google, is referred to your booking page and completes a booking. | A conversion event would be sent with Token A and merchant changed value of 2 because the user was referred to the booking page by Google. |
3 | A user (originating from Google) begins the booking flow, but abandons the session before the booking is completed. Note: Keep this session open for Test 4 and 5. |
A user is referred to your booking page but the session ends and they don't complete a booking. | No conversion because the user did not complete the booking but Token B should be stored for 30 days. |
4 | A user returns to the booking page, without having been originating from Google, and completes a booking. Note: The booking flow URL must not include an rwg_token. |
A user returns to the booking page after Test #4. Token B should be stored for 30 days and any conversion during those 30 days should return a conversion event. | A conversion event would be sent with Token B and merchant changed value of 2 because the user is returning to the booking page after previous referral from Google. |
5 | A user completes a new booking originating from Google after Test #4. | If a user returns to your booking page using a Google referral after a previous Google referral, their 30-day storage window resets and a new token Token C replaces the old one Token B. All future conversions will then be attributed to Token C. | A conversion event would be sent with Token C and merchant changed value of 2 because the user completed the booking and the new token replaced the previously stored token. |
If you have a platform with the ability for users to checkout with a different merchant, test the following.
Test Case | Test Description | User Flow | Expected Outcome |
---|---|---|---|
6 | A user is referred to your booking page by Google and completes a booking with a different merchant. | A user is referred to your booking page by Google, Token A is used, but before completing a booking they navigate to a different page and complete the booking with a merchant that differs from the original referral. | A conversion event would be sent because the user completed a booking that originated with a referral from Google with Token A and merchant changed value of 1 because the user completed the booking in a different merchant than the referral. |
While you test, send the HTTP POST request to the conversion endpoint. There are two endpoints:
- Production environment: https://www.google.com/maps/conversion/collect
- Sandbox environment: https://www.google.com/maps/conversion/debug/collect
Test Tokens
To test conversion tracking, add one of the following test tokens to the end of the Action links or booking page URLs you provide in your feeds.
Token A:
rwg_token=AJKvS9WeONmWKEwjG0--HdpzMq0yAVNL8KMxbb44QtbcxMhSx_NUud5b8PLUBFehAIxOBO-iYRIJOknEFkIJmdsofdVJ6uOweQ%3D%3D
Token B:
rwg_token=AJKvS9U2QfiQanHFQrlJxBjD0AyFany3qpaJVEWOcY4nHqY_UkLYFFDj6RIa-EXS1iEmV8gtFPG6v1cU1jnusJK66ijXXnaqkQ%3D%3D
Token C:
rwg_token=AJKvS9VwInjZ_hGZPvBz0COVWJ5oFDzocFt9hGi7TMurlo2l71uiXP48PspPUMmRnqCUDE1mF_A5H_dMV78cBTF8jIfSQK6lEA%3D%3D
When you send the successful conversion events, you can see them aggregated in the Action Center under the conversion tracking dashboard.
Requirements for Conversion Attribution
Google's required standard for conversion attribution is a 30 days attribution window for any interaction with a place action link, at any store.
This attribution window means that Google can expect a conversion event to be sent in any of the following scenarios:
- A user follows a place action link and places an order for the same merchant in the same session. Merchant change value = 2.
- A user follows a place action link and then returns from a different channel within the 30 days attribution window to place an order for the same merchant. Merchant change value = 2.
- A user follows a place action link and then places an order at a different store, either within the same session or a different session within a 30 days attribution window. Merchant change value = 1.
Additionally, Google expects to send conversion events from any device, a user can access through a place action link. These devices include:
- Desktop or mobile web applications.
- Mobile apps, either through an app deep link or a registered app-intent for your domain.
If the token is stored at the user-level, it's expected that you provide cross-device attribution. For more information, see Store at User-Level. In this case, a user who follows an action link from the desktop and then completes the transaction on mobile with the same user account, must trigger a conversion event.
If the token is stored exclusively at the device-level, such as in browser cookies, it's not expected that you provide cross-device attribution. In this case, each device can have a separate token persisted, if the user follows an action link on that device, and each device can follow the attribution rules separately.