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 }},
To:
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: {{ product.id|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
}
}]);
</script>
<!-- for klaviyo added to cart -->
<script type="text/javascript">
var _learnq = _learnq || a];
document.getElementById("AddToCart").addEventListener('click',function (){
_learnq.push(n'track', 'Added to Cart', item]);
});
</script>
{% endif %}
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,
Alex
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
Thanks