Tracking script

in Development
Hey,
Im creating a lightspeed app and I need to inject a tracking script in the body / head of a lightspeed shop. When i use the endpoint ShopTracking I dont see the script added to the shop html. Its a js code so the ShopScript endpoint is not going to work for me because i don't need add a js file. The ShopJavascript is working and i can see the added js code in the shop html but the documentation says to not use this endpoint for apps. Can someone help me please?
Thanks
Tags:
6 comments
Hi,
I'm not sure if I understand your question correctly.
You can add tracking scrips here: https://developers.lightspeedhq.com/ecom/endpoints/shoptracking/
You can add javascript here:
https://developers.lightspeedhq.com/ecom/endpoints/shopscript/
Yeah but if i add a tracking script with this the script is not showing in de shops html. And i dont need to add a js file so this one https://developers.lightspeedhq.com/ecom/endpoints/shopscript/ is not gonna work for me.
Tracking scripts are added to the <head>.
In order to add a script the body, you can upload the script somewhere and use the shopscript to load it (via the url) into a shop.
If you do not want to do that, you can ask the merchant to add the script manually in their theme or in Settings > Web Extras > CustomJS. Another option would be to use the shopjavascript, but you should keep in mind that this is meant to be for changes on shop level and the merchant has access and can change this.
Yeah exactly, so thats the problem when I use the tracking script it is not adding anything to the <head>. This is my post request body:
{
"shopTracking":{
"isEnabled":true,
"content":"console.log('test');"
}
}
When I do a request a get back a 201 created. And when I do a get tracking scripts request I see the script. But when i look in the <head> of the shop I don's see anything.
Hi @gerbenzwemer,
The web tracking / shop tracking code can only be executed on your Thank You page after customers place an order.
Okay thank you!