Solved

Track user "Active on Site" event from server side

  • 18 July 2023
  • 3 replies
  • 210 views

Userlevel 1
Badge +3

New API, same question :)

 

I can’t find any documentation on how to send user activity using your new API https://developers.klaviyo.com/en/reference/create_event

 

Also it will be great if you can help me understand how to send “$viewed_items” parameter from old API.

 

Thanks.

 

p.s. I am updating server GTM tag to new API version https://tagmanager.google.com/gallery/#/owners/stape-io/templates/klaviyo-tag and that’s why have this questions.

 

Old Question:

 

icon

Best answer by Brian Turcotte 27 July 2023, 20:34

View original

3 replies

Userlevel 7
Badge +36

Hi @Stape!

I’m going to check on this with Engineering and I’ll get back to you ASAP!

 

Best,

Brian

Userlevel 7
Badge +36

Hi @Stape!
 

I was able to recreate the CURL request that solved your old post using the new V3 Create Event endpoint, here:

curl --request POST \
--url https://a.klaviyo.com/api/events/ \
--header 'Authorization: Klaviyo-API-Key API_KEY' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'revision: 2023-07-15' \
--data '
{
"data": {
"type": "event",
"attributes": {
"properties": {
"page": "https://website.com/",
"browser": "Chrome",
"os": "Mac",
"$use_ip": "true",
"$is_session_activity": "true"
},
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": "__activity__"
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"properties": {
"$referrer": "{ \"ts\":1614270576, \"value\":\"\", \"first_page\":\"https://website.com/\" }",
"$last_referrer": "{ \"ts\":1617046396, \"value\":\"\", \"first_page\":\"https://website.com/\" }"
},
"email": "email@gmail.com"
}
}
}
}
}
}
'

 

Per your second question, server-side calls do not allow you to include viewed item information - that is only allowed via the JavaScript API as outlined in our developer documentation here:

 

I hope this helps, and thanks for using the Community!

- Brian

Userlevel 1
Badge +3

@Brian Turcotte Thanks for the help

Reply