Pulling a specific customer Tag from Shopify

Good Morning, I currently have a flow that relies on pulling the Klaviyo ID from customer tags in Shopify. The problem I'm running into is that most customers have multiple tags which makes it difficult to extract the correct tag which starts with "Klaviyo ID:" for example "Klaviyo ID: 01G1TZJE4G2PYFW01AFCSD46N8". I would like to extract the tag that starts with "Klaviyo ID: " and only use the value after that.

0

Comments

3 comments
Date Votes
  • Hi Shadner Joseph

    You can add a transformation to extract the value of the Klaviyo ID. sample screenshot below. 

    {{substring tags (regexSearch tags 'Klaviyo ID:([^\\s]+)') (add (regexSearch tags 'Klaviyo ID:([^\\s]+)') 38)}}
    0
  • Shadner Joseph to build on Sree Vani Amara's response, if you don't want the "Klaviyo ID: " piece of the string, since I assume you need just the id to map to Klaviyo, you can use the below handlebar expression. This will extract just the id, works if the tag is beginning, middle, or end of the tag string, and doesn't rely on hardcoded string lengths in case something changes down the road.

    {{regexMatch tags "(?<=Klaviyo ID: )([A-Za-z0-9_-]+)" 0 "g"}}

    0
  • Tyler Lamparter and Sree Vani Amara

    Thank you so much!

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post