{"_id":"57c876099e6bca0e007edebc","__v":1,"category":{"_id":"57fa65275ba65a17008b988f","__v":0,"version":"5668fab608f90021008e8832","project":"5668fab608f90021008e882f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-10-09T15:41:27.321Z","from_sync":false,"order":7,"slug":"model-query-javascript","title":"Model query (Javascript)"},"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"},"user":"5668fa9755e4b32100935d41","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-01T18:40:09.806Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"For our standard JavaScript integration, we identify a user across pageviews using first-party user identifier cookies stored under the website's domain, as described at [Cookies and Local Storage](doc:cookies-and-local-storage) for more information). Unfortunately, this solution does not work to identify users across sites. If you are interested in cross-site recommendations (showing recommendations from one of your websites to users on another) then our first-party cookie system is insufficient.\n\nNote that if you are running fetch multiple times in a page (for both within-site and cross-site recommendations) you may want to enable multiFetch as described in the [$p(\"init\")](doc:pinit) documentation.\n\n[block:api-header]\n{\n  \"title\": \"Cross-site recommendations by JavaScript key\"\n}\n[/block]\nIf you have multiple domains, each with a separate JavaScript key, you can request cross-site recommendations by specifying a JavaScript key in the opts, both when you register and when you track. For instance, the following is a quick test to see that you can return LiftIgniter recommendations on your website.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Register call to get 100 recommendations for widget 'default-widget'.\\n// Apply a simple callback to print out the JSON response.\\n$p('register', {\\n\\tmax: 100, // Large number requested so you can see our full range of items\\n  widget: 'default-widget', // name of widget\\n \\topts: {jsk: \\\"vba4vdhq7eo382ub\\\"},\\t\\t\\t\\t\\t\\t\\t\\n  callback: function(resp) {\\n\\t\\tconsole.log(JSON.stringify(resp, null, 2));\\n  }\\n});\\n// Execute the registered call.\\n$p('fetch');\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nAnd the following is the skeleton for implementing registering, rendering, and tracking functionality for LiftIgniter recommendations on your site. Basically, you'll follow the same process to render and track recommendations as described in the \"Model query (Javascript)\" section of our documentation, but you must include the jsk in the opts for register and track.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Register call to get 100 recommendations for widget 'default-widget'.\\n// Apply a simple callback to print out the JSON response.\\n$p('register', {\\n\\tmax: 100, // Large number requested so you can see our full range of items\\n  widget: 'default-widget', // name of widget\\n \\topts: {jsk: \\\"vba4vdhq7eo382u\\\"},\\t\\t\\t\\t\\t\\t\\t\\n  callback: function(resp) {\\n\\t\\tconsole.log(JSON.stringify(resp, null, 2));\\n  \\tconsole.log(\\\"// TEST.\\\");\\n    // In order to launch recs in production, please reference the documentations on Rendering Widgets and Tracking Widgets:\\n    // $p('render', ...) \\n    $p(\\\"track\\\", {\\n      elements: ...\\n      ...,\\n      opts: {jsk: \\\"vba4vdhq7eo382u\\\"},\\n    })\\n  }\\n});\\n// Execute the registered call.\\n$p('fetch');\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Receiving ML-trained cross-site recommendations requires activation by LiftIgniter\",\n  \"body\": \"Please be in touch with the LiftIgniter team at support:::at:::liftigniter.com in order to be have this feature activated. In order to protect customer separation, as well as for quality control purposes, we activate cross-site model training between properties only upon customer request. Without requesting us, you will receive a mostly static list of popular recommendations rather than context-specific or user-specific recommendations.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Cross-site recommendations from backend\"\n}\n[/block]\nIf you are using [Model Queries from Backend](doc:model-queries-from-backend) (i.e., sending the model query from the backend), then for cross-site recommendations, you need to make sure of the following:\n\n* The API key you use should be of the property for which you want recommendations.\n* The `url` or `id` field that you include should be from the original property.\n* Please include the `gid` field as instructed at [Model Queries from Backend](doc:model-queries-from-backend).","excerpt":"","slug":"cross-site-recommendation","type":"basic","title":"Cross-site recommendation"}

Cross-site recommendation


For our standard JavaScript integration, we identify a user across pageviews using first-party user identifier cookies stored under the website's domain, as described at [Cookies and Local Storage](doc:cookies-and-local-storage) for more information). Unfortunately, this solution does not work to identify users across sites. If you are interested in cross-site recommendations (showing recommendations from one of your websites to users on another) then our first-party cookie system is insufficient. Note that if you are running fetch multiple times in a page (for both within-site and cross-site recommendations) you may want to enable multiFetch as described in the [$p("init")](doc:pinit) documentation. [block:api-header] { "title": "Cross-site recommendations by JavaScript key" } [/block] If you have multiple domains, each with a separate JavaScript key, you can request cross-site recommendations by specifying a JavaScript key in the opts, both when you register and when you track. For instance, the following is a quick test to see that you can return LiftIgniter recommendations on your website. [block:code] { "codes": [ { "code": "// Register call to get 100 recommendations for widget 'default-widget'.\n// Apply a simple callback to print out the JSON response.\n$p('register', {\n\tmax: 100, // Large number requested so you can see our full range of items\n widget: 'default-widget', // name of widget\n \topts: {jsk: \"vba4vdhq7eo382ub\"},\t\t\t\t\t\t\t\n callback: function(resp) {\n\t\tconsole.log(JSON.stringify(resp, null, 2));\n }\n});\n// Execute the registered call.\n$p('fetch');", "language": "javascript" } ] } [/block] And the following is the skeleton for implementing registering, rendering, and tracking functionality for LiftIgniter recommendations on your site. Basically, you'll follow the same process to render and track recommendations as described in the "Model query (Javascript)" section of our documentation, but you must include the jsk in the opts for register and track. [block:code] { "codes": [ { "code": "// Register call to get 100 recommendations for widget 'default-widget'.\n// Apply a simple callback to print out the JSON response.\n$p('register', {\n\tmax: 100, // Large number requested so you can see our full range of items\n widget: 'default-widget', // name of widget\n \topts: {jsk: \"vba4vdhq7eo382u\"},\t\t\t\t\t\t\t\n callback: function(resp) {\n\t\tconsole.log(JSON.stringify(resp, null, 2));\n \tconsole.log(\"// TEST.\");\n // In order to launch recs in production, please reference the documentations on Rendering Widgets and Tracking Widgets:\n // $p('render', ...) \n $p(\"track\", {\n elements: ...\n ...,\n opts: {jsk: \"vba4vdhq7eo382u\"},\n })\n }\n});\n// Execute the registered call.\n$p('fetch');", "language": "javascript" } ] } [/block] [block:callout] { "type": "warning", "title": "Receiving ML-trained cross-site recommendations requires activation by LiftIgniter", "body": "Please be in touch with the LiftIgniter team at support@liftigniter.com in order to be have this feature activated. In order to protect customer separation, as well as for quality control purposes, we activate cross-site model training between properties only upon customer request. Without requesting us, you will receive a mostly static list of popular recommendations rather than context-specific or user-specific recommendations." } [/block] [block:api-header] { "title": "Cross-site recommendations from backend" } [/block] If you are using [Model Queries from Backend](doc:model-queries-from-backend) (i.e., sending the model query from the backend), then for cross-site recommendations, you need to make sure of the following: * The API key you use should be of the property for which you want recommendations. * The `url` or `id` field that you include should be from the original property. * Please include the `gid` field as instructed at [Model Queries from Backend](doc:model-queries-from-backend).