amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Provide ability to conditionally append key-value pair in amp-analytics

Open britice opened this issue 10 years ago • 5 comments

In some analytics platforms, when a parameter is empty the expected behavior is to not include that parameter in the request. For example, if there was an optional user-defined authors variable and the user left the value undefined, the request would not contain an authors parameter.

britice avatar Feb 01 '16 16:02 britice

Is this blocking for your integration?

rudygalfi avatar Feb 04 '16 17:02 rudygalfi

Is this blocking for your integration?

No. We've tested our systems with empty query params and everything is working as expected. At this time, this issue is not a high priority from Chartbeat's perspective.

britice avatar Feb 05 '16 16:02 britice

@cramforce @avimehta LMK if this works:

I intend to implement this as a new boolean config option, skipEmptyUrlParams, which, when true, will omit "vars" and "extraUrlParams" if the value is anything other than a non-empty string.

jmadler avatar Feb 11 '16 18:02 jmadler

vars can't be omitted like that. For example, lets say this is my config:

{
  "requests": { "foo": "/foo?bar=${baz}" },
  "vars": { "baz" = "" }
}

In this case, regardless of the value of `baz`, the parameter `bar` will always be there. It's value will be empty if `baz` is empty but it will still be sent over wire. 

avimehta avatar Feb 11 '16 18:02 avimehta

This hasn't been discussed in awhile. Closing since it's pretty low in priority but we can reopen if anyone has a specific need for this.

rudygalfi avatar May 01 '17 21:05 rudygalfi