Re: Automatically add utm parameters to links

SanfordWhiteman
Level 10 - Community Moderator

Re: Automatically add utm parameters to links

To my knowledge if a link contains a blank utm_parameter with & following it should skip it in GA and add the next one.

Yep, a query key with no value (&key& or &key=&) is considered a param with an empty value (rather than an error).

Grégoire_Miche2
Level 10

Re: Automatically add utm parameters to links

Hi Sanford Whiteman,

what happens if a utm parameter value contains white spaces? For instance, the {{program.name}} user may contain white spaces such as "My New Gated Content Program"

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Automatically add utm parameters to links

The web browser -- the app that makes the HTTP connection -- should URL-encode those spaces to %20 automatically (we usually try to do this before the link is placed in the page, but in reality modern browsers will take care of it for you).

Anonymous
Not applicable

Re: Automatically add utm parameters to links

Erik,

Do the variable have to be in a "module". I have been trying to do the same thing by just defining the meta class and then using the ${"id"} in the template HTML (<a href="${cta-url}${cta-utm-tag}" ...) but, while the variable for the CTA button works fine in the editor, I am unable to see or edit the actual URL.

Thanks,

Eddie

SanfordWhiteman
Level 10 - Community Moderator

Re: Automatically add utm parameters to links

You can use standalone variables, if that's what you're asking. But don't include the protocol ("http​://" or "http​://") in the variable -- keep that hard-coded.

Anonymous
Not applicable

Re: Automatically add utm parameters to links

Thanks for the reply Sanford.

So, I was able to get the form field to appear in the editor under Global Variables by formatting like this:

<a href="https://"${cta-url}${cta-utm-tag} ...>

However, when I add values and then preview the code the href value comes across as:

<a href="https://" ${cta-url}${cta-utm-tag}="" ...>

Sending a test results in a broken link.

I am going to keep toying with it but if you can enlighten me, I would appreciate it. Thanks!

Eddie

SanfordWhiteman
Level 10 - Community Moderator

Re: Automatically add utm parameters to links

The whole URL must be enclosed in quotes, not the protocol only.

Anonymous
Not applicable

Re: Automatically add utm parameters to links

Sanford - I fixed it. Rookie mistake.

<a href="https://${cta-url}${cta-utm-tag}" ...>

Works fine. I was just puzzled as to why I could not get the variables to appear in the editor when I formatted the href like that the first time.

Mysteries.

Thanks again.

Eddie