{"_id":"57fab0f2a44f4920003e9e1d","__v":0,"category":{"_id":"56e1ff6aa49fdc0e005746b5","__v":2,"pages":["56e218eabf97591700e72321","56e218fd30de321700b7e8d2"],"project":"5668fab608f90021008e882f","version":"5668fab608f90021008e8832","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-03-10T23:12:42.527Z","from_sync":false,"order":8,"slug":"js-sdk-api-integration","title":"JS SDK + API Integration"},"githubsync":"","user":"5668fa9755e4b32100935d41","parentDoc":null,"project":"5668fab608f90021008e882f","version":{"_id":"5668fab608f90021008e8832","__v":19,"project":"5668fab608f90021008e882f","createdAt":"2015-12-10T04:08:22.769Z","releaseDate":"2015-12-10T04:08:22.769Z","categories":["5668fab708f90021008e8833","569740f124490c3700170a64","569742b58560a60d00e2c25d","569742bd0b09a41900b2446c","569742cd69393517000c82b3","569742f459a6692d003fad8f","569743020b09a41900b2446d","5697430b69393517000c82b5","56a17776470ae00d00c30642","56a2c48a831e2a0d0069b1ad","56b535757bccae0d00e9a1cd","56e1ff6aa49fdc0e005746b5","57e1c88115bf6522002a5e4e","57fa65275ba65a17008b988f","57fbeea34002550e004c032e","58474584889b6c2d00fb86e9","58475dcc64157f0f002f1907","587e7b5158666c2700965d4e","58a349fc30852819007ba083"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.18.0","version":"1.18"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-09T21:04:50.606Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"If you are tracking our recommendations built from backend model queries, then you don't need to run the `track` function in the callback to `register`. Just run the `track` function by itself on the page.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$p('track', {\\n    // track LI recommendations\\n    elements: document.querySelectorAll('#li-recommendation-unit > div.recommended_item'),\\n    name: 'default-widget',\\n    source: 'LI',\\n    _debug : true  // Optional: show alerts on click or visible events (to know that the integration is working); ***remove prior to launch***\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNote that `elements` field is the list of elements that contains the recommendation. Our tracking function identifies all the anchors within specified DOM and attaches listeners that will tell us what kind of recommendations the user have viewed, and take feedback from every click they make on them.\n\nSource is the name of the algorithm that was used to create recommendation. For A/B testing, we use default name 'LI' for LiftIgniter and 'base' for your own algorithm. Any other name will be logged to our system. But won't be rendered instantly on the board until it is registered.\n\nFor more details, see our [technical documentation on the track function](doc:ptrack).\n\nKeep in mind that [Load order](doc:load-order) issues can get in the way of successful tracking. So make sure this tracking code is executed after the relevant selectors have been loaded into the page.","excerpt":"","slug":"standalone-widget-tracking","type":"basic","title":"Standalone widget tracking"}

Standalone widget tracking


If you are tracking our recommendations built from backend model queries, then you don't need to run the `track` function in the callback to `register`. Just run the `track` function by itself on the page. [block:code] { "codes": [ { "code": "$p('track', {\n // track LI recommendations\n elements: document.querySelectorAll('#li-recommendation-unit > div.recommended_item'),\n name: 'default-widget',\n source: 'LI',\n _debug : true // Optional: show alerts on click or visible events (to know that the integration is working); ***remove prior to launch***\n});", "language": "javascript" } ] } [/block] Note that `elements` field is the list of elements that contains the recommendation. Our tracking function identifies all the anchors within specified DOM and attaches listeners that will tell us what kind of recommendations the user have viewed, and take feedback from every click they make on them. Source is the name of the algorithm that was used to create recommendation. For A/B testing, we use default name 'LI' for LiftIgniter and 'base' for your own algorithm. Any other name will be logged to our system. But won't be rendered instantly on the board until it is registered. For more details, see our [technical documentation on the track function](doc:ptrack). Keep in mind that [Load order](doc:load-order) issues can get in the way of successful tracking. So make sure this tracking code is executed after the relevant selectors have been loaded into the page.