Percent Encoding of Custom Parameters

389 views
Skip to first unread message

Dorian Kind

unread,
May 10, 2016, 4:43:10 AM5/10/16
to AdWords API Forum
Hello,

Is there a reference somewhere about which characters are being automatically percent-encoded by the Adwords API when setting custom parameters?

I've noticed that any characters outside basic ASCII seem to always be encoded, but for the first 128 the behavior seems less clear. For example, curly, square and angle brackets are being escaped (but not regular parentheses). A double quote will be escaped, but not a single one.

However most of the reserved characters which have to be *always* percent-encoded according to RFC 3986 are not being escaped (with the exception of the square brackets, as mentioned).

It's not a problem at all of doing the encoding on our end, but it would help to exactly know for which characters it is being done at the API level. For the ValueTrack parameter {escapedlpurl} for instance, it's specified that only :, /, ?, =, and % will be escaped. 

Thanks for any feedback and best regards,
Dorian

Shwetha Vastrad (AdWords API Team)

unread,
May 10, 2016, 12:45:47 PM5/10/16
to AdWords API Forum
Hi Dorian,

You can use this document as a reference for ValueTrack parameters. The characters which are escaped depends on what variant of the ValueTrack parameter you are using. For example, the {lpurl} is the landing page url escaped as per standard URL specifications. The characters being escaped also depends on the position of the parameter in the tracking template. If {lpurl} is not at the beginning of your tracking template, it escapes the single quote character along with the characters ?,=,",#,\t, and [space]. 

I hope this helps. 

Regards,
Shwetha, AdWords API Team.

Dorian Kind

unread,
May 10, 2016, 12:55:01 PM5/10/16
to AdWords API Forum
Hi Shwetha,

thanks for your quick reply. I'm afraid the ValueTrack documentation isn't of much help, though. What I'm observing is that custom parameters are neither being handled "as per standard URL specifications" (as not all reserved characters are escaped) nor does the escaping for {lpurl} apply (as the character { is being percent-encoded, for example).
Actually we're just going to do all URL-encoding on our end so it's not really relevant, but I'm still curious about what the exact behavior is.

Cheers,
Dorian

Thanet Knack Praneenararat (AdWords API Team)

unread,
May 11, 2016, 2:00:01 AM5/11/16
to AdWords API Forum
Hi Dorian,

Let me check in detail.
Will update this thread once I have an answer.

Best,
Thanet, AdWords API Team

Thanet Knack Praneenararat (AdWords API Team)

unread,
May 12, 2016, 2:03:28 AM5/12/16
to AdWords API Forum
Hi Dorian,

For custom parameters, if they're used in a final URL and the final URL is used in tracking template then they're escaped with final URL 
So the list of escaped char depends on if {lpurl} or {escapedlpurl} is used.

If they're used directly in the tracking template, they're not escaped.

Best,
Thanet, AdWords API Team

On Wednesday, May 11, 2016 at 1:55:01 AM UTC+9, Dorian Kind wrote:

Dorian Kind

unread,
May 12, 2016, 8:43:11 AM5/12/16
to AdWords API Forum
Hi Thanet,

I'm not sure if that's correct. To me it seems that there's clearly some percent-encoding going on:


Or am I misunderstanding you?


Thanks & cheers,

Dorian

Thanet Knack Praneenararat (AdWords API Team)

unread,
May 13, 2016, 4:14:55 AM5/13/16
to AdWords API Forum
Hi Dorian,

Let me check with the relevant team again.
I'll update this thread soon.

Best,
Thanet, AdWords API Team

Thanet Knack Praneenararat (AdWords API Team)

unread,
May 31, 2016, 1:35:54 PM5/31/16
to AdWords API Forum
Hello Dorian,

Sorry for the delay.
Could you please share your tracking template too, apart from the final URL and custom parameters in the below image?

Thanks in advance.

Best,
Thanet, AdWords API Team

Dorian Kind

unread,
Jun 1, 2016, 3:50:47 AM6/1/16
to AdWords API Forum
Hi Thanet,

thanks for getting back! I actually didn't use a tracking template in the example for which I provided a screenshot. But I recreated a similar one below, this time including a tracking template:




I think what's most notable is that the question mark, the ampersand and the percent sign are not being escaped and could make the query string unparsable for some web servers. Also, if a custom parameter contains a pound sign, everything after it will be considered a fragment and not used for the click URL. Like I mentioned before, we URL-encode all custom parameters before sending them to the API, so it's not a problem for us. But it might be helpful if the behavior was documented.


Thanks again and best regards,

Dorian

Thanet Knack Praneenararat (AdWords API Team)

unread,
Jun 1, 2016, 5:29:47 AM6/1/16
to AdWords API Forum
Hi Dorian,

Thanks for information.
I'll pass that to the engineering team.

Best,
Thanet, AdWords API Team

Thanet Knack Praneenararat (AdWords API Team)

unread,
Jun 16, 2016, 2:50:11 AM6/16/16
to AdWords API Forum
Hi Dorian,

Sorry for keeping you waiting.
It appears that the click URL shown in UI isn't the same one used to serve ads.
So, what you understand originally is correct--customer parameters aren't percent-encoded.

The engineering team is going to make a change so the click URL shown in UI aligns with what's used to serve ads.

Best,
Thanet, AdWords API Team
Reply all
Reply to author
Forward
0 new messages