Skip to main content
Solved

add a counter to an attribute


Hello!
Could you please tell me how i can increment (increase) the value of the attribute in customer.io ?
for example i have an attribute, called ‘number_of_page_views’ and i want it to increase it’s value by 1, every time user logins the page. (1,2,3,4 etc).

Best answer by alex_mustafa

@Felix this worked for me:

{% if customer.number_of_page_views != blank %}
  {{customer.number_of_page_views | plus: 1 }}
{% else %}
  {{ 1 }}
{% endif %}

View original

4 replies

Felix
  • Novice
  • 210 replies
  • March 6, 2023

Hey Alex,

as long as you send an event or webhook to CIO in case the user logs in, you can do the following:

Create a campaign and simple add “create or update a person” in the workflow. There you can select your attribute number_of_page_views and use liquid to increase the value by 1 with the filter “plus” (in my case it named the attribute page_views):

 

Hope that helps,

Felix


Hey, Felix!
i did according to your advice.
It works fine if person has number_of_page_views attribute, but in case it does not have it,  there is an error. 
In case attribute number_of_page_views does not exist yet, we would like it to be created and incremented.
Can you please give an advice how we could fix this ?
Here are the screenshots of my current configuration,
Thanks in advance!
 


 



 

 


  • Author
  • Novice
  • 2 replies
  • Answer
  • April 7, 2023

@Felix this worked for me:

{% if customer.number_of_page_views != blank %}
  {{customer.number_of_page_views | plus: 1 }}
{% else %}
  {{ 1 }}
{% endif %}


Felix
  • Novice
  • 210 replies
  • April 24, 2023

@alex_mustafa That would have been my solution as well. I think you don’t need the brackets before and after 1, but as long as it works you are good to go :)

 

Best,
Felix


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings