Fix common formatting issues for custom parameters

30/11/2019

This article goes over how to format your custom parameters, and troubleshoot issues with how your tag was added to your site. It includes instructions on adding Javascript code and alternatives to your website, and common ways that code can get mixed up.

Before you begin

To get started using custom parameters, first read how to Tag your website for dynamic remarketing.

A note on ampersands (&)

Ampersands must be encoded as "&" inside of HTML code (in the src attribute), but not inside of JavaScript code. Many tags and containers that allow the piggybacking of pixels (like Floodlight) expect the URLs to not be HTML-encoded. This leads to frequent errors of double-encoding ampersands which leads to improper tracking. Make sure you use proper URL depending on the context. If you're unsure, use the Google Tag Assistant chrome extension to verify your implementation.

Use Google Tag Manager

You can use Google Tag Manager instead of adding the dynamic remarketing tags to your site. This option routes the tagdata through a third-party (Google).

Formatting custom parameters

  • For pages with multiple IDs like shopping cart pages, use brackets to group IDs. Example: flight_destid: ["123", "456"]
  • Use single or double quotes for string custom parameters. Either single or double quotes will work, but should always be consistent. Example: If you choose to use single quotes, use them for all values.
  • Don’t use quotes for numerical custom parameters. Example: flight_totalvalue: 200.99
  • Separate parameters with commas. If you don't include commas, the tag won't work properly.
  • Custom parameters can only contain letters, digits, and underscores. Custom parameters shouldn’t begin with digits or include spaces.
  • For optimal setup, use the recommended values in this article because these will form lists that Google Ads already creates for you when you set up your dynamic remarketing campaign. Additional values can be used to define other pages specific to your site.

Examples of custom parameters

Here's an example for an airline's website with all the basic custom parameters implemented.

Site section Custom parameter tag sample Notes
Home On the homepage, you have information about the page type.

Although there may not be any product or service information on these pages, Google Ads can still pull products and services from your feed based on what is likely to perform the best.
Search results page On the search results page, you have information about the page type.
Offer detail page On the offer detail page, you can dynamically fill in information about the product or service being viewed. Use the same ID from your feed.
Cart page Single destination


Multiple destinations
On the cart page you should send all the items you have in the cart. When you have multiple values in a parameter, use a JavaScript array (brackets). In the "xxxxxxxx_totalvalue" parameter, you need to send the sum of the values in the cart.
Purchase page Single destination


Multiple destinations
The purchase confirmation page should also have all products that someone bought. In the "xxxxxxxx_totalvalue" parameter you need to send the sum of the values in the cart or on the conversion page.
All other pages On all other pages, use other for xxxxxxxx_pagetype.

Although there may not be any product or service information on these pages, Google Ads can still pull products and services from your feed based on what is likely to perform the best.

Common errors when setting up custom parameters

Below are some of the common mistakes people make when they implement custom parameters using the example of an airline website. If you use Tag Assistant, you'll be able to identify most of these common mistakes.

1. String values are not quoted. For example:

Should be changed to:

Single quotes also work, as long as they are used consistently.

2. Custom parameters are not separated by a comma (","). For example:

Should be changed to:

The last custom parameter doesn't need to have "," after it. But it's OK if it does.

3. Parameter contains space or non-ASCII characters. We only support [a-z][0-9] and '_'. For example:

Should be changed to:

4. Multiple values in a parameter without brackets. For example:

Should be changed to:

5. Parameter with no value. For example:

Should be changed to:

 

or simply:

6. Incorrect naming convention for custom parameters. For example:

Should be changed to:

Using non-Javascript tags

We recommend using the JavaScript tag over the non-JavaScript image tag because it leads to fewer implementation errors and addresses several HTML goals. The non-JavaScript image tag is treated like an image. Since some web browsers cache images to speed up the time it takes for a page to load, the tag will only be activated the first time someone visits your website but not during subsequent visits. The JavaScript version of the tag fixes this.

You can use these instructions if you want to use the non-JavaScript part of the tag (also known as the image tag) or if you want to have a shorter version of the tag. The image tag doesn't require the JavaScript library (conversion.js) and the loading of the image happens in parallel with the page loading.

You need to customize the non-JavaScript portion of the remarketing tag so it can still send values. The data needs to be manually encoded.

Take the tag you've just created. The tag should look like this example:




The highlighted text is the non-JavaScript tag. Follow these steps to send your custom parameters through the remarketing tag:

1. Prepare the custom parameters (also called key/values) you'd like to send to Google Ads. The key/values should be sent in the following format:

data.key1=val1&data.key2=val2&data.key2=val3...

For example, if you want to send flight_destid=100 and flight_pagetype=purchase as custom parameters, they should be arranged like this:

data.flight_destid=100&data.flight_pagetype=purchase

If a given key has multiple values, say multiple product or service ids on a shopping cart page, add another data.flight_destid= for each extra value.

data.flight_destid=101&data.flight_destid=102&data.flight_pagetype=cart

2. Append the string to pixel’s URL as parameters, and then HTML encode the & to &

3. After the change, the final img src looks like this:

//googleads.g.doubleclick.net/pagead/viewthroughconversion/XXXXXXXXXX/?value=0&guid=ON&script=0&data.flight_destid%3D101&data.flight_destid=102
&data.flight_pagetype=purchase

4. Below is the final img tag, which you can put on your site. It gives you the same functionality as the JavaScript version of the tag.

* Nguồn: Google