Search through more than a hundred articles on every aspect of User.com

Alex Nowak
Written by Alex Nowak

How to create product events

Learn how to send product events with our widget's API


General information

Product events are created the same way as regular events. However, there are three things you need to remember:

Firstly, you need to use a keyword "product_event".

Secondly, you must include these two attributes:

  1. product_id 
  2. event_type 

There is also one more thing that doesn't affect how you create the event, but it's closely related: we don't store information about the attributes’ values in each event. Attributes, apart from event_type, are updated with the latest value sent, which is then stored in the product’s profile (meaning that each event updates the values of all the attributes in previous events). Such an approach makes it far more efficient when you are sending tens of millions of events every month. 

However, this means you won’t be able to access or use past values of those attributes. To be able to differentiate, for example, the same shoes in different sizes, you need to create a separate product for each size.

When it comes to event_type, you can use only the types listed below:

  • add to cart
  • purchase
  • liking
  • add to observation
  • order
  • reservation
  • return
  • view
  • click
  • detail
  • add
  • remove
  • checkout
  • checkout option
  • refund
  • promo click

Remember!

Passing the name of your product in the event is not mandatory. However, if you don't include such an attribute and the product with its own ID was not created beforehand, the product will be created without a name.

Example code 

userengage('product_event', {product_id: 'the_id', event_type: 'add to cart', 'name': 'product name', 'my_attribute': 'value', 'my_attribute_2': 'value_2'})

You can also insert your product event within HTML and trigger it e.g., on click.

<a href="#" onclick="userengage('product_event', {product_id: 'the_id', event_type: 'add to cart', 'name': 'product name', 'my_attribute': 'value', 'my_attrbiute_2': 'value_2'})">CLICK ME!</a>

API 

Once you create product events, it may be useful in the long term to use the API's enpoints like Get user's product events details or Get user's product events details by custom ID. It is also possible to filter the results by Product Event type by adding the parameter ?type=<product_event_type_id>.

The full list of Product Event types is given below:

  • ADD_TO_CART = 1
  • PURCHASE = 2
  • LIKING = 3
  • ADD_TO_OBSERVATION = 4
  • ORDER = 5
  • RESERVATION = 6
  • RETURN = 7
  • VIEW = 8
  • CLICK = 9
  • DETAIL = 10
  • ADD = 11
  • REMOVE = 12
  • CHECKOUT = 13
  • CHECKOUT_OPTION = 14
  • REFUND = 15
  • PROMO_CLICK = 16
Categories: