Skip to main content

IF Formula to find character in URL and concatenate UTM depending on IF.

  • September 27, 2023
  • 1 reply
  • 32 views

Forum|alt.badge.img+1

Sometimes we have URLs that include "?" for example www.mytravelsite.com/deals?destination=florida. Its best practise when adding UTMs that if a url already includes a "?" then the UTM should start with "&" instead. 

The below is the expected outcome of this.

www.mytravelsite.com/deals?destination=florida&utm_source=Offsite_P195&utm_medium=Patnerships_Video&utm_campaign=VisitFlorida_Sep-Oct2023_YouTube

This is the formula i have attempted to use.

IF(FIND("?", {Landing Page (from Campaign)}), CONCATENATE({Landing Page (from Campaign)},"&utm_source=",{Source (from Product)},"&utm_medium=",{Medium (from Product)},"&utm_campaign=",Name), CONCATENATE({Landing Page (from Campaign)},"?utm_source=",{Source (from Product)},"&utm_medium=",{Medium (from Product)},"&utm_campaign=",Name))

This is what its returning, which is incorrect. 

www.mytravelsite.com/deals?destination=florida?utm_source=Offsite_P195&utm_medium=Patnerships_Video&utm_campaign=VisitFlorida_Sep-Oct2023_YouTube

Can anyone help me?

1 reply

TheTimeSavingCo
Forum|alt.badge.img+31

Hmm I realize this post is super old but that spam bot pulled it up again and I thought it was an interesting problem; here’s my take on a solution which seems to work:

{Landing Page (from Campaign)} & 
IF(
FIND("?", {Landing Page (from Campaign)}),
'&',
'?'
) &
"utm_source=" & {Source (from Product)} &
"&utm_medium=" & {Medium (from Product)} &
"&utm_campaign=" & Name