Solved

Setting page view tracking in HTTP request

  • 24 August 2023
  • 3 replies
  • 508 views

Hello Amplitude team

 

I’m currently using React/Nextjs for the company’s app and we recently setup Amplitude in our codebase using the HTTP API method. The tracking of the events on the page button seems to be working as I could see the data reflected in our Amplitude account. However, when I inspect the event, the event_properties declared here which is url shows no value. This property is added for the purpose of tracking this particular url/page as I’m unsure how to include the pageView default setting. There are examples for the SDK method but not for the HTTP API. Appreciate if you could provide some insight on this. Currently, this is how we set up the api call;


try {
const _res = await axios.post(
'https://api2.amplitude.com/2/httpapi',
{
api_key: project_key,
events: [
{
device_id: deviceId,
event_type: 'signup_button',
event_property: {
url: router.asPath
}
}
]
},
{
withCredentials: false
}
);
} catch (error) {
alert(error);
}

 

icon

Best answer by Saish Redkar 30 August 2023, 11:38

View original

3 replies

Userlevel 7
Badge +10

Hi @Aznim Rahman 

Usually when sending data via the SDKs there are options to capture certain parameters by default. But when using the HTTP API, you need to explicitly set the value for your event properties while posting. So if your “router.asPath” value is getting resolved correctly , you should see the url value being captured in the raw event after ingestion. Are you seeing none values for this property or is it not available in your chart dropdowns?

Hi. As per my previous post regarding this issue, I have attached a screenshot of the url property. It is not showing any value here on Amplitude. Below is the same screenshot where it doesn’t display the values at all. This url value is however shown on payload in my console. 

 

 

Userlevel 7
Badge +10

Hi @Aznim Rahman 

The above screenshot won’t show you the actual value of url captured.

You will have to go to a user’s event stream and verify if your ‘signup_button’ event is indeed capturing the url property value in the raw event.

Reply