Skip to main content
Stape
Contributor III
Contributor III
July 18, 2023
Solved

Track user "Active on Site" event from server side

  • July 18, 2023
  • 3 replies
  • 581 views

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:

 

    This topic has been closed for replies.
    Best answer by Brian Turcotte

    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

    3 replies

    Brian Turcotte
    Klaviyo Alum
    July 19, 2023

    Hi @Stape!

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

     

    Best,

    Brian

    Brian Turcotte
    Klaviyo Alum
    July 27, 2023

    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

    Stape
    Contributor III
    StapeAuthor
    Contributor III
    August 24, 2023

    @Brian Turcotte Thanks for the help