Derive Property REGEXEXTRACT & logic help

  • 2 September 2021
  • 3 replies
  • 831 views

Badge

Hello everyone,

I’m pretty new to Amplitude and not very experienced with regular expressions, hoping for some help with my formula please.

Background:  We operate overlay or banner ads on our website and, in this case, when a user clicks on one of these call to action buttons we pass a utm_content parameter which contains “yield” in the query string of the destination URL.

I have something incorrect, a combination of a incorrect regular expression for “Contains” using REGEXEXTRACT, and/or my logic is incorrect with the statement.

Here’s the Formula I currently have:

IF(

    REGEXEXTRACT(utm_content, "/yield") == "yield",

        'true',

        'false'

    )

When I create this Derived Property and select it, I only receive “false” as a filter option - so the function is incorrect and never resolves as true.

 


Now, if I use a straight utm_content property then I can see all the campaigns where this occurs:
 


Many thanks!


3 replies

Userlevel 7
Badge +10

Hey @bward 
Looks like the regex formula is trying to match a “/” at the start of “yield” and the possible values in the utm_content property only start with “yield” in the property dropdown screenshot.

Also, if your value contains a “/” , the right way to try matching that would be to escape the value using a backslash “\” at the start of a “/”. You can also try using a “^” in the pattern if you want to match a string at the beginning of each value.

Can you try using REGEXEXTRACT(utm_content, "yield") == "yield" and see if that works?

Badge

Thanks @Saish Redkar - I’ve tried both of those which didn’t happen to change my “False” only result, this makes me wonder if I’ve got the Properties or the rest of the formula mixed up.  I’ll give it some thought and try a few other things.

Thanks again!

Userlevel 4
Badge +7

Hi @bward! I’m wondering if you ever figured out why the formula didn’t work? Do you need any help troubleshooting this still? 

Reply