amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Add ability to specify extraUrlParams at trigger level

Open rudygalfi opened this issue 10 years ago • 3 comments

extraUrlParams behaves a lot like vars but can only appear at the top-level of a config. This means that every request in that config includes extra params. It may be desirable to not have extra URL params on certain requests, which could be done by doing the definition at the trigger level.

Open issue: How should precedence work? If you have the extraUrlParams defined at both the trigger and top-level, do you: (a) ignore the top-level definition entirely (b) naively combine the two configs, meaning allow duplicate definitions for a param to appear (c) smartly combine the two configs, meaning don't allow a duplication definition for a param (and prefer the trigger-level definition)

/cc @avimehta @jmadler

rudygalfi avatar Mar 03 '16 22:03 rudygalfi

cc @cory-work

rudygalfi avatar Mar 04 '16 01:03 rudygalfi

FWIW, I would expect it to work like the vars, meaning option (c). For example, if I so something like

{
    "requests": {
        "test": "example.com?a=${a}&b=${b}&c=${c}"
    },
    "vars": {
        "a": "outer",
        "c": "outer"
    },
    "triggers": {
        "trackButton1Click": {
            "on": "click",
            "selector": "#button1",
            "request": "test",
            "vars": {
                "a": "inner",
                "b": "inner"
            }
        }
    }
}
  • The generated URL is https://example.com?a=inner&b=inner&c=outer . The trigger-level is favored, but if not specified it falls back to the top-level.

Tonsil avatar Mar 16 '16 20:03 Tonsil

@Tonsil That makes sense. I think that is the way we'll go.

avimehta avatar Mar 16 '16 20:03 avimehta