Solved

add a counter to an attribute

  • 5 March 2023
  • 4 replies
  • 175 views

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).

icon

Best answer by alex_mustafa 7 April 2023, 19:20

View original

4 replies

Userlevel 4

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!
 


 



 

 

@Felix this worked for me:

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

Userlevel 4

@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