Skip to main content
Solved

Track user "Active on Site" event from server side


Stape
Contributor III
Forum|alt.badge.img+3
  • Contributor III
  • 6 replies

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:

 

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @Stape!

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

 

Best,

Brian


Brian Turcotte
Forum|alt.badge.img+37

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
Forum|alt.badge.img+3
  • Author
  • Contributor III
  • 6 replies
  • August 24, 2023

@Brian Turcotte Thanks for the help