Klaviyo Flow evaluating price as string instead of number? Broken?

Badge +1

We’ve created a simple test flow, when someone views a product, if the product is over $1.00 to send an email to The problem is the the “price” is being passed to Klaviyo with the currency symbol ($) in it.

So instead of 75.49, it is passing $75.49. Therefore, the price is no longer a number but in fact a string and therefore Klaviyo flow cannot evaluate if the price is greater than 1 or not, because it is effectively evaluating if letters > 1 (which is always false).

How can we fix this, please?


Best answer by alex.hong 13 May 2022, 22:03

View original

3 replies

Badge +1

I think it’s related to the theme > templates > product.liquid theme file, specifically the two colorized parts below. I think the fix is just to change:

Price: {{ product.price|money|json }},


Price: {{ product.price|money_without_currency|json }},

If any minds smarter than my own could advise if that is correct it would be greatly appreciated!


{% if settings.newsletter_form_type == 'klaviyo' %}
<script type="text/javascript" defer="defer">
  var _learnq = _learnq || [];

  var item = {
    Name: {{ product.title|json }},
    ProductID: {{|json }},
    Categories: {{ product.collections|map:'title'|json }},
    ImageURL: "https:{{ product.featured_image.src|img_url:'grande' }}",
    URL: "{{ shop.secure_url }}{{ product.url }}",
    Brand: {{ product.vendor|json }},
    Price: {{ product.price|money|json }},
    CompareAtPrice: {{ product.compare_at_price_max|money|json }}

  _learnq.push(['track', 'Viewed Product', item]);
  _learnq.push(['trackViewedItem', {
    Title: item.Name,
    ItemId: item.ProductID,
    Categories: item.Categories,
    ImageUrl: item.ImageURL,
    Url: item.URL,
    Metadata: {
      Brand: item.Brand,
      Price: item.Price,
      CompareAtPrice: item.CompareAtPrice

<!-- for klaviyo added to cart -->
<script type="text/javascript">
  var _learnq = _learnq || [];
  document.getElementById("AddToCart").addEventListener('click',function (){
      _learnq.push(['track', 'Added to Cart', item]);
{% endif %}

Userlevel 7
Badge +58

Hi there @cookwarecanucks,

Welcome to the Community!

If you look at the event payload for your add to cart or product, you'll see that the Price value should include a currency symbol.
What this means is that the Price value comes in as a string data type. A string/text data type cannot have numerical properties, such as the ability to filter the value as being greater than or less than a number. 
The root cause of this is that you need to change the way this data is being passed into Klaviyo so that it comes into Klaviyo as a numerical value. The Added to Cart snippet actually refers to the "item" variable which is defined in the Viewed Product snippet. Therefore, you need to update the Viewed Product snippet so that the Price value is a number and not a string/text. 
Please update the Price variable within the Viewed Product snippet to:

Price: {{ product.price|divided_by:100.0|json }}

Once you update the Viewed Product snippet, then you should begin to see both the Viewed Product events and Added to Cart events being passed into Klaviyo with a numerical Price value going forward. That will enable you to filter/split the Flow by the numerical value of the event. 


Let me know if that helped,


Badge +2

If I don’t want to change the code in the website how I can do this in the campaign email itself?

I tried removing the dollar $ sign but it’s still not evaluating it as a string it seems. I also couldn’t find a function to convert a string to numeric?

For example event.Price = $359 will trigger the first if statement. 

{% if event.Price|find_replace:"$| " >= 400 %}

$50 discount
 {% elif event.Price|find_replace:"$| " >= 150 %} 

$30 discount