Forum Discussion

CarolineS's avatar
6 years ago

Maintain URL parameters in a page initialization script redirect?

Hi team!

I'm not really a developer (as I imagine will be evident in my question below), but trying to cobble this one together. Could use some help!

So... I've realized that some of our google UTM tracking has been broken due to a redirect we do in our page initialization script. This redirects community.meraki.com to a top-level category URL under specific conditions.

BUT - there are also a number of links out there in the world to community.meraki.com/?utm_source=something&utm_medium=somethingelse

Unfortunately, these UTM parameters are lost in the redirect, and they're not being picked up by Google at all because (I believe!?) the page initialization script runs (& does the redirect) before our Google Analytics code runs.

So, I could use some help maintaining the UTM parameters (and whatever other URL parameters are present) in my redirect.

Currently the code is:

${http.response.setRedirectStatus(301)}
${http.response.setRedirectUrl(merakiCommunityHomeUrl)}

I've found this nice document about Lithium's http.response methods: https://freemarker-docs-portal.lithium.com/refer/contextObjects#httpResponse - it doesn't seem like there's a quick & easy way to pass the parameters.

I imagine I could extract the parameters from the original URL and append them to my merakiCommunityHomeUrl, but that's a bit beyond my skills. Help!

THANK YOU!

  • CarolineS,

    You can first check the parameter values in parameter and store in the variable.something like:

    <#assign utm_source = http.request.parameters.name.get("utm_source", "") />
    <#assign utm_medium = http.request.parameters.name.get("utm_medium", "") />

    and pass these values if present to url along with redirect parameter something like this:

    ${merakiCommunityHomeUrl}?utm_source=${utm_source}&utm_medium=${utm_medium}

     

  • CarolineS,

    You can first check the parameter values in parameter and store in the variable.something like:

    <#assign utm_source = http.request.parameters.name.get("utm_source", "") />
    <#assign utm_medium = http.request.parameters.name.get("utm_medium", "") />

    and pass these values if present to url along with redirect parameter something like this:

    ${merakiCommunityHomeUrl}?utm_source=${utm_source}&utm_medium=${utm_medium}