{"_id":"56a18d1bd847b50d00a27735","project":"5668fab608f90021008e882f","category":{"_id":"56a17776470ae00d00c30642","version":"5668fab608f90021008e8832","__v":5,"project":"5668fab608f90021008e882f","pages":["56a1827ad847b50d00a27729","56a1831f44f3d80d00a2c3c9","56a18a6244f3d80d00a2c3d3","56a18a83932d7c0d008bf231","56a18d1bd847b50d00a27735"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-22T00:27:34.102Z","from_sync":false,"order":5,"slug":"inventory","title":"Inventory (JavaScript)"},"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"},"parentDoc":null,"__v":14,"user":"56839cf74aecbd0d00a4659e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-22T01:59:55.764Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example\"\n}\n[/block]\nHere’s a worked-out example where you have some fields in the JSON object and some as Open Graph fields:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script id=\\\"liftigniter-metadata\\\" type=\\\"application/json\\\">\\n{\\n    \\\"title\\\" : \\\"5 Cool Ways to Eat an Apple\\\",\\n    \\\"tags\\\" : [\\\"apple\\\", \\\"cool\\\", \\\"nutrition\\\"]\\n}\\n</script>\\n<meta property=\\\"og:title\\\" content=\\\"These 5 Cool Ways to Eat An Apple Left Me Salivating. You'd NEVER Think of #3.\\\"/>\\n<meta property=\\\"og:url\\\" content=\\\"http://viral-website.com/eating-apples/\\\">\\n<meta property=\\\"og:description\\\" content=\\\"Boy, was I wrong to think I knew how to eat an apple!\\\"/>\\n<meta property=\\\"og:image\\\" content=\\\"http://cdn.viral-website.com/winking-apple.jpg\\\"/>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNow suppose you request all these fields when requesting our recommendations:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$p(\\\"setRequestFields\\\", [\\\"url\\\",\\\"title\\\",\\\"tags\\\",\\\"image\\\",\\\"thumbnail\\\",\\\"description\\\",\\\"subtitle\\\"]);\\n$p(\\\"fetch\\\");\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe JSON object for this item will be as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"url\\\" : \\\"http://viral-website.com/eating-apples/\\\",\\n  \\\"title\\\" : \\\"5 Cool Ways to Eat an Apple\\\",\\n  \\\"tags\\\" : [\\\"apple\\\", \\\"cool\\\", \\\"nutrition\\\"],\\n  \\\"image\\\" : \\\"http://cdn.viral-website.com/winking-apple.jpg\\\",\\n  \\\"thumbnail\\\" : \\\"http://cdn.viral-website.com/winking-apple.jpg\\\",\\n  \\\"description\\\" : \\\"Boy, was I wrong to think I knew how to eat an apple!\\\"\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNote that the title field in the LiftIgniter JSON object overwrites the og:title. The subtitle field is not returned because we didn’t have a value for that field.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Special fields: title, url and thumbnail\"\n}\n[/block]\nFor the title field, we use the following order of precedence:<ul>\n<li>`title` as specified in the LiftIgniter JSON object in the page HTML.</li>\n<li>`og:title` in the page HTML.</li>\n<li>The current title of the page.</li>\n</ul>\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"We have noticed that some customers include the site name in their page title, but may not want to display the site name when showing the page in a recommendation widget. You can either send us the correct title in the JSON object or do a transformation at your end after receiving the title to remove the site name.\",\n  \"title\": \"Notes on displaying site name\"\n}\n[/block]\nFor the url field, we use the following order of precedence to determine the correct URL:\n<ul>\n<li>`url` as specified in the LiftIgniter JSON object in the page HTML.</li>\n<li>The href field for link rel=`canonical` in the page source.</li>\n<li>`og:url` in the page HTML.</li>\n<li>The current URL of the page, after stripping out all tags (anything after a `?` symbol) and everything after a hash symbol.</li>\n</ul>\n\nIt’s particularly important that you specify canonical URLs so as to avoid us returning recommendations that duplicate each other or duplicate the user’s recent browsing history.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"We have noticed that a number of websites that engage in social sharing use separate subdomains for social sharing that redirect to the same articles. Please make sure that the canonical URL you specify is the same for all the versions of the page, including the ones shared on social media. Otherwise, we might have trouble identifying pages correctly.\",\n  \"title\": \"Matching subdomain\"\n}\n[/block]\nFor the thumbnail field, we return a copy of the image field (for which we check the LiftIgniter JSON object first and then check the `og:image` tag) unless you have specified a thumbnail field in the custom LiftIgniter JSON object.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Global rules\"\n}\n[/block]\nWe currently support some simple rules surrounding what items we return in recommendations. These rules need to be activated manually by the LiftIgniter team and may take a few days to activate. We intend to eventually offer support for a more flexible rule system. This section will be updated when we update our rule system.\n\nThe rules we currently support are:\n<ul>\n<li>Global exclusion: Always exclude items satisfying some condition (such as a particular tag, or a numerical score above or below some threshold) from recommendations.</li>\n<li>Exclusions based on optional parameters: Based on some optional parameters you pass in in your SDK query, we can exclude items satisfying a particular condition.</li>\n<li>Global boost: We can boost content satisfying conditions (such as a tag or a title term). However, the way we currently implement boosts does not offer any guarantee of how much more often the boosted content will show up.</li>\n<li>Boost based on optional parameters: These are boosts that are activated only if you pass in optional parameters.</li>\n</ul>\n\nWe have one global exclusion rule activated by default. If you include a field called \"noShow\" with value \"true\" in the LiftIgniter JSON object, then the item will be included in our inventory but will never be returned in recommendations.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script id=\\\"liftigniter-metadata\\\" type=\\\"application/json\\\">\\n{\\n  ...\\n  \\\"noShow\\\" : \\\"true\\\",\\n  ...\\n}\\n</script>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nFor other global exclusion rules, please get in touch with the LiftIgniter team. It can take us up to one week to activate your rule framework.\n\nNote that pages where you mark \"noIndex\" as \"true\" won’t enter our inventory at all and will never be recommended. However, for low-quality items, we recommend using `noShow` instead of `noIndex`. That’s because having an item in the inventory, even if we never show it, allows us to show better recommendations if the user is currently on, or has recently visited, such a page.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Forbid us from indexing some items\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"noShow is recommended\",\n  \"body\": \"We do support this feature, but using `noShow` instead  of `noIndex` is better in most cases.\"\n}\n[/block]\nWhen we start working with you, we determine the type of site you have and the area where you want to show recommendations, and configure our system to pick up the right types of inventory items.\n\nIn some cases, there might be items that look like inventory items, but that you don’t actually want us to treat as inventory items. Examples are:\n<ul> \n<li>Site contact pages or other site information pages.</li>\n<li>Temporary article pages created for experimentation such as A/B testing titles.</li>\n</ul>\nFor such pages, add a field `noIndex` with value `true` in the custom LiftIgniter JSON object:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script id=\\\"liftigniter-metadata\\\" type=\\\"application/json\\\">\\n{\\n  ...\\n  \\\"noIndex\\\" : \\\"true\\\",\\n  ...\\n}\\n</script>\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nWe do not recommend the use of `noIndex` for cases where you want us to avoid showing low-quality items that are legitimately in the inventory.\n\nNote that it may take us up to 24 hours to drop an item from the inventory after a \"noIndex\" tag is applied.","excerpt":"","slug":"examples-and-exceptions","type":"basic","title":"Examples and Exceptions"}

Examples and Exceptions


[block:api-header] { "type": "basic", "title": "Example" } [/block] Here’s a worked-out example where you have some fields in the JSON object and some as Open Graph fields: [block:code] { "codes": [ { "code": "<script id=\"liftigniter-metadata\" type=\"application/json\">\n{\n \"title\" : \"5 Cool Ways to Eat an Apple\",\n \"tags\" : [\"apple\", \"cool\", \"nutrition\"]\n}\n</script>\n<meta property=\"og:title\" content=\"These 5 Cool Ways to Eat An Apple Left Me Salivating. You'd NEVER Think of #3.\"/>\n<meta property=\"og:url\" content=\"http://viral-website.com/eating-apples/\">\n<meta property=\"og:description\" content=\"Boy, was I wrong to think I knew how to eat an apple!\"/>\n<meta property=\"og:image\" content=\"http://cdn.viral-website.com/winking-apple.jpg\"/>", "language": "javascript" } ] } [/block] Now suppose you request all these fields when requesting our recommendations: [block:code] { "codes": [ { "code": "$p(\"setRequestFields\", [\"url\",\"title\",\"tags\",\"image\",\"thumbnail\",\"description\",\"subtitle\"]);\n$p(\"fetch\");", "language": "javascript" } ] } [/block] The JSON object for this item will be as follows: [block:code] { "codes": [ { "code": "{\n \"url\" : \"http://viral-website.com/eating-apples/\",\n \"title\" : \"5 Cool Ways to Eat an Apple\",\n \"tags\" : [\"apple\", \"cool\", \"nutrition\"],\n \"image\" : \"http://cdn.viral-website.com/winking-apple.jpg\",\n \"thumbnail\" : \"http://cdn.viral-website.com/winking-apple.jpg\",\n \"description\" : \"Boy, was I wrong to think I knew how to eat an apple!\"\n}", "language": "javascript" } ] } [/block] Note that the title field in the LiftIgniter JSON object overwrites the og:title. The subtitle field is not returned because we didn’t have a value for that field. [block:api-header] { "type": "basic", "title": "Special fields: title, url and thumbnail" } [/block] For the title field, we use the following order of precedence:<ul> <li>`title` as specified in the LiftIgniter JSON object in the page HTML.</li> <li>`og:title` in the page HTML.</li> <li>The current title of the page.</li> </ul> [block:callout] { "type": "info", "body": "We have noticed that some customers include the site name in their page title, but may not want to display the site name when showing the page in a recommendation widget. You can either send us the correct title in the JSON object or do a transformation at your end after receiving the title to remove the site name.", "title": "Notes on displaying site name" } [/block] For the url field, we use the following order of precedence to determine the correct URL: <ul> <li>`url` as specified in the LiftIgniter JSON object in the page HTML.</li> <li>The href field for link rel=`canonical` in the page source.</li> <li>`og:url` in the page HTML.</li> <li>The current URL of the page, after stripping out all tags (anything after a `?` symbol) and everything after a hash symbol.</li> </ul> It’s particularly important that you specify canonical URLs so as to avoid us returning recommendations that duplicate each other or duplicate the user’s recent browsing history. [block:callout] { "type": "info", "body": "We have noticed that a number of websites that engage in social sharing use separate subdomains for social sharing that redirect to the same articles. Please make sure that the canonical URL you specify is the same for all the versions of the page, including the ones shared on social media. Otherwise, we might have trouble identifying pages correctly.", "title": "Matching subdomain" } [/block] For the thumbnail field, we return a copy of the image field (for which we check the LiftIgniter JSON object first and then check the `og:image` tag) unless you have specified a thumbnail field in the custom LiftIgniter JSON object. [block:api-header] { "type": "basic", "title": "Global rules" } [/block] We currently support some simple rules surrounding what items we return in recommendations. These rules need to be activated manually by the LiftIgniter team and may take a few days to activate. We intend to eventually offer support for a more flexible rule system. This section will be updated when we update our rule system. The rules we currently support are: <ul> <li>Global exclusion: Always exclude items satisfying some condition (such as a particular tag, or a numerical score above or below some threshold) from recommendations.</li> <li>Exclusions based on optional parameters: Based on some optional parameters you pass in in your SDK query, we can exclude items satisfying a particular condition.</li> <li>Global boost: We can boost content satisfying conditions (such as a tag or a title term). However, the way we currently implement boosts does not offer any guarantee of how much more often the boosted content will show up.</li> <li>Boost based on optional parameters: These are boosts that are activated only if you pass in optional parameters.</li> </ul> We have one global exclusion rule activated by default. If you include a field called "noShow" with value "true" in the LiftIgniter JSON object, then the item will be included in our inventory but will never be returned in recommendations. [block:code] { "codes": [ { "code": "<script id=\"liftigniter-metadata\" type=\"application/json\">\n{\n ...\n \"noShow\" : \"true\",\n ...\n}\n</script>", "language": "javascript" } ] } [/block] For other global exclusion rules, please get in touch with the LiftIgniter team. It can take us up to one week to activate your rule framework. Note that pages where you mark "noIndex" as "true" won’t enter our inventory at all and will never be recommended. However, for low-quality items, we recommend using `noShow` instead of `noIndex`. That’s because having an item in the inventory, even if we never show it, allows us to show better recommendations if the user is currently on, or has recently visited, such a page. [block:api-header] { "type": "basic", "title": "Forbid us from indexing some items" } [/block] [block:callout] { "type": "warning", "title": "noShow is recommended", "body": "We do support this feature, but using `noShow` instead of `noIndex` is better in most cases." } [/block] When we start working with you, we determine the type of site you have and the area where you want to show recommendations, and configure our system to pick up the right types of inventory items. In some cases, there might be items that look like inventory items, but that you don’t actually want us to treat as inventory items. Examples are: <ul> <li>Site contact pages or other site information pages.</li> <li>Temporary article pages created for experimentation such as A/B testing titles.</li> </ul> For such pages, add a field `noIndex` with value `true` in the custom LiftIgniter JSON object: [block:code] { "codes": [ { "code": "<script id=\"liftigniter-metadata\" type=\"application/json\">\n{\n ...\n \"noIndex\" : \"true\",\n ...\n}\n</script>", "language": "javascript" } ] } [/block] We do not recommend the use of `noIndex` for cases where you want us to avoid showing low-quality items that are legitimately in the inventory. Note that it may take us up to 24 hours to drop an item from the inventory after a "noIndex" tag is applied.