Guide
Analytics Tracking
Purchase Data
1 min
tab examples url https analytics url analytics producttracking name reporting single order data method get request pathparameters queryparameters kind required name klevu apikey type string description this is your klevu js api key kind required name klevu type type string description this is constant value the value must be checkout kind required name klevu productid type string description this is the klevu id of the clicked product eg 54321 12345 kind required name klevu productgroupid type string description this is the parent id of the clicked product eg 54321 for compound products with a parent and multiple child variant products this is the common id which ties the products together for simple products please specify the same as klevu productid kind required name klevu productvariantid type string description this is the child variant id of the clicked product eg 12345 for compound products with a parent and multiple child variant products this is the id of the specific variant for simple products please specify the same as klevu productid kind required name klevu unit type integer description this is the total quantity purchased it must be an integer e g 5 kind required name klevu saleprice type number description product s sale price for one unit you can supply decimal values kind required name klevu currency type string description three digit currency code e g gbp usd eur kind required name klevu shopperip type string description ip address of the shopper who bought the product s n n if calling from javascript this is an optional parameter name klevu shopperip v4 kind optional type string description ipv4 address of the shopper who purchased a product children name klevu shopperip v6 kind optional type string description ipv6 address of the shopper who purchased a product children name data protection kind optional type boolean description if set to false klevu s backend do not obtain the shoppers ip address the default value is true children name klevu uuid kind optional type string description universally unique identifier generated by klevu it can be also considered as session id please obtain uuid using end point https docs klevu com apis uuid children name klevu country kind optional type string description 2 digit country code of the shopper who purchased a product valid codes can be found at https developers google com hotels hotel prices dev guide country codes children name klevu city kind optional type string description city name of the shopper who purchased a product children headerparameters bodydataparameters formdataparameters results languages id ddxomvwnislr jx48ghqd code data n response success response n data language 200 customlabel selectedlanguageid ddxomvwnislr jx48ghqd examples languages id ewnrzcoksk8s4pdjfvhym code ?php n n curl curl init ; n ncurl setopt array curl array n curlopt url https stats ksearchnet com analytics producttracking?klevu apikey klevu 1234567890 klevu type checkout klevu productid 54321 12345 klevu productgroupid 54321 klevu productvariantid 12345 klevu unit 2 klevu saleprice 123 45 klevu currency gbp n curlopt returntransfer true n curlopt encoding n curlopt maxredirs 10 n curlopt timeout 0 n curlopt followlocation true n curlopt http version curl http version 1 1 n curlopt customrequest get n ; n n response curl exec curl ; n ncurl close curl ; necho response; n language curl customlabel id eqqdeuhwckdcwovoowpgc code var request require request ; nvar options n method get n url https stats ksearchnet com analytics producttracking?klevu apikey klevu 1234567890 klevu type checkout klevu productid 54321 12345 klevu productgroupid 54321 klevu productvariantid 12345 klevu unit 2 klevu saleprice 123 45 klevu currency gbp n headers n n ; nrequest options function error response n if error throw new error error ; n console log response body ; n ; n language nodejs customlabel id 8jgvxehuuib8hjb3wwgyb code var xhr new xmlhttprequest ; nxhr withcredentials false; n nxhr addeventlistener readystatechange function n if this readystate 4 n console log this responsetext ; n n ; n nxhr open get https stats ksearchnet com analytics producttracking?klevu apikey klevu 1234567890 klevu type checkout klevu productid 54321 12345 klevu productgroupid 54321 klevu productvariantid 12345 klevu unit 2 klevu saleprice 123 45 klevu currency gbp ; n nxhr send ; language javascript customlabel id 6dgdwewxlcomg0snanahm code import requests n nurl https stats ksearchnet com analytics producttracking?klevu apikey klevu 1234567890 klevu type checkout klevu productid 54321 12345 klevu productgroupid 54321 klevu productvariantid 12345 klevu unit 2 klevu saleprice 123 45 klevu currency gbp n npayload nheaders n nresponse requests request get url headers headers data payload n nprint response text n language python customlabel id zx8 wo0tig8ycfpmpqeio code require uri nrequire net http n nurl uri https stats ksearchnet com analytics producttracking?klevu apikey klevu 1234567890 klevu type checkout klevu productid 54321 12345 klevu productgroupid 54321 klevu productvariantid 12345 klevu unit 2 klevu saleprice 123 45 klevu currency gbp n nhttps net http new url host url port nhttps use ssl true n nrequest net http get new url n nresponse https request request nputs response read body n language ruby customlabel selectedlanguageid ewnrzcoksk8s4pdjfvhym description use this api endpoint to submit the purchase data per product nthe request should be made once for each line item purchased n currentnewparameter label query parameter value queryparameters tab examples url https analytics url analytics collect name reporting multiple order data json method post request pathparameters queryparameters headerparameters bodydataparameters kind required name event version type string description the event version is used by klevu s backend the current version is 1 0 0 kind required name event type string children description define the type of event for order use a constant value order purchase kind required name event apikey type string children description your klevu js api key eg klevu 12345 name event timestamp ms kind optional type number description event timestamp in milliseconds e g 1736256722349 children name user profile kind required type object description the json object that holds the user related information such as ip address email the json object that holds the user related information such as ip address email children name ip address kind required type string description ip address of the shopper who purchased the product n if calling from javascript this is an optional parameter n name email kind optional type string description email id of the shopper who purchased the product n name ip address v4 kind optional type string description ipv4 address of the shopper who purchased a product name ip address v6 kind optional type string description ipv6 address of the shopper who purchased products name data protection kind optional type boolean description if set to false klevu s backend do not obtain the shoppers ip address the default value is true name klevu uuid kind optional type string description universally unique identifier generated by klevu it can be also considered as session id name klevu country kind optional type string description 2 digit country code of the shopper who purchased products valid codes can be found at https developers google com hotels hotel prices dev guide country codes name klevu city kind optional type string description city name of the shopper who purchased products schema name ip address kind required type string description ip address of the shopper who purchased the product n if calling from javascript this is an optional parameter n name email kind optional type string description email id of the shopper who purchased the product n name ip address v4 kind optional type string description ipv4 address of the shopper who purchased a product name ip address v6 kind optional type string description ipv6 address of the shopper who purchased products name data protection kind optional type boolean description if set to false klevu s backend do not obtain the shoppers ip address the default value is true name klevu uuid kind optional type string description universally unique identifier generated by klevu it can be also considered as session id name klevu country kind optional type string description 2 digit country code of the shopper who purchased products valid codes can be found at https developers google com hotels hotel prices dev guide country codes name klevu city kind optional type string description city name of the shopper who purchased products kind required name items type array children description depending on the number of orders the item array accepts single or more orders kind optional name order id type string children description the unique identifier for your orders kind optional name order line id type string children description the unique identifier for reference to a line on an order within the database kind required name item name type string children description the name of the product kind required name item id type string children description the full id of the product eg 12345 54321 this will match the unique value used in your data sync process with klevu for compound products consisting of a child variant and a parent this is usually parentid childid kind required name item group id type string children description the parent id of the product eg 12345 for compound products consisting of a child variant and a parent please specify the id of the parent for simple products please re use the same value as item id kind required name item variant id type string children description the child id of the product eg 54321 please specify the id of the child variant product for simple products please re use the same value as item id kind required name unit price type number children description the final selling price of the product for example 123 45 kind required name currency type string children description the currency of the above price eg usd kind optional name units type integer children description the number of units sold for a product in case if the parameter is mising the default value will be 1 formdataparameters results languages id fi7dvhqck3 p270nihihk code language 200 customlabel selectedlanguageid fi7dvhqck3 p270nihihk examples languages id djsrpqrxfqsrjfnj4p wd code ?php n n curl curl init ; n ncurl setopt array curl array n curlopt url https stats ksearchnet com analytics collect n curlopt returntransfer true n curlopt encoding n curlopt maxredirs 10 n curlopt timeout 0 n curlopt followlocation true n curlopt http version curl http version 1 1 n curlopt customrequest post n curlopt postfields n n event order purchase n event apikey klevu 12345 n user profile n ip address 111 11 11 1 n email user klevu com n n event version 1 0 0 n event data n items n n order id 1223434 n order line id abc 12343 n item name 45ru 800x1070 n type d nos cm wh ea n item id 75882 n item group id 75882 n item variant id 75882 n unit price 6033 42 n currency usd n units 2 n n n order id 1223435 n order line id abc 12344 n item name nos cm wh ea n item id 75883 n item group id 75883 n item variant id 75883 n unit price 6033 42 n currency us n units 1 n n n n n n curlopt httpheader array n content type application json n n ; n n response curl exec curl ; n ncurl close curl ; necho response; language php customlabel id edjoaar2zbyzaldipyefn code warning for post requests body is set to null by browsers nvar data json stringify n n event order purchase n event apikey klevu 12345 n user profile n ip address 111 11 11 1 n email user klevu com n n event version 1 0 0 n event data n items n n order id 1223434 n order line id abc 12343 n item name 45ru 800x1070 n type d nos cm wh ea n item id 75882 n item group id 75882 n item variant id 75882 n unit price 6033 42 n currency cad n units 2 n n n n n ; n nvar xhr new xmlhttprequest ; nxhr withcredentials false; n nxhr addeventlistener readystatechange function n if this readystate 4 n console log this responsetext ; n n ; n nxhr open post https stats ksearchnet com analytics collect ; nxhr setrequestheader content type application json ; n nxhr send data ; language javascript customlabel id zzumafhlxj 2brmng3ssl code okhttpclient client new okhttpclient newbuilder n build ; nmediatype mediatype mediatype parse application json ; nrequestbody body requestbody create mediatype n n event order purchase n event apikey klevu 12345 n event version 1 0 0 n event data n items n n order id 1223434 n order line id abc 12343 n item name 45ru 800x1070 n type d nos cm wh ea n item id 75882 n item group id 75882 n item variant id 75882 n unit price 6033 42 n currency cad n units 2 n n n n n ; nrequest request new request builder n url https stats ksearchnet com analytics collect n method post body n addheader content type application json n build ; nresponse response client newcall request execute ; language java customlabel id d8ae l0vu6r3vbktka0iz code var request require request ; nvar options n method post n url https stats ksearchnet com analytics collect n headers n content type application json n n body json stringify n n event order purchase n event apikey klevu 1234 n user profile n ip address 111 11 11 1 n email user klevu com n n event version 1 0 0 n event data n items n n order id 1223434 n order line id abc 12343 n item name 45ru 800x1070 n type d nos cm wh ea n item id 75882 n item group id 75882 n item variant id 75882 n unit price 6033 42 n currency cad n units 2 n n n n n n n ; nrequest options function error response n if error throw new error error ; n console log response body ; n ; n language nodejs customlabel selectedlanguageid djsrpqrxfqsrjfnj4p wd description the end point is used for reporting multiple orders in batch currentnewparameter label body parameter value bodydataparameters