{"_id":"57e025a9031bca0e00460d6c","user":"5668fa9755e4b32100935d41","__v":0,"category":{"_id":"569743020b09a41900b2446d","__v":3,"pages":["56975be30b09a41900b24494","56a15cfd470ae00d00c3061f","56e356004dc30f0e0051b3ed"],"project":"5668fab608f90021008e882f","version":"5668fab608f90021008e8832","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-01-14T06:41:06.893Z","from_sync":false,"order":2,"slug":"javascript-sdk","title":"JavaScript SDK"},"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-09-19T17:51:37.681Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":5,"body":"`$p(\"sendRobust\"): (String, Object) -> Boolean`\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$p(\\\"sendRobust\\\", \\\"widget_click\\\", {\\n  clickUrl: \\\"http://asdfasdf.com/asdf\\\", // for widget_click event\\n  customContextA : \\\"value1\\\",\\n  customContextB : \\\"value2\\\"\\n})\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Used for custom tracking functions\",\n  \"body\": \"For an example of how sendRobust is used for sending widget click events, see our documentation on [Tracking with no Anchor](doc:tracking-with-no-anchor).\"\n}\n[/block]\n`sendRobust` sends an event to LiftIgniter just like the `send` function. However, it's different from `send` in that it queues the event in a buffer, and sends it on user's new pageview to make sure that the event is sent. This takes care of the case where page redirect happens before sending the click event. \n\nThe function returns `false` if local storage and cookies are unavailable as a buffer. So if you want to add a small frame of time (let's say for instance, 100 ms), you can consider the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if(!$p(\\\"sendRobust\\\",\\\"widget_click\\\", {\\\"clickUrl\\\":\\\"url\\\"})){\\n  $p(\\\"send\\\",\\\"widget_click\\\", {\\\"clickUrl\\\":\\\"url\\\"});\\n  // event object will be passed from any click listener that you implement.\\n  // https://developer.mozilla.org/en-US/docs/Web/API/Event\\n  if (!event.metaKey && !event.shiftKey && event.type == \\\"click\\\") {\\n    event.preventDefault();\\n    win.setTimeout(function() {\\n      win.location.href = url;\\n    }, 100);\\n  } \\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"psendrobust","type":"fn","title":"$p(\"sendRobust\")"}
`$p("sendRobust"): (String, Object) -> Boolean` [block:code] { "codes": [ { "code": "$p(\"sendRobust\", \"widget_click\", {\n clickUrl: \"http://asdfasdf.com/asdf\", // for widget_click event\n customContextA : \"value1\",\n customContextB : \"value2\"\n})", "language": "javascript" } ] } [/block] [block:callout] { "type": "info", "title": "Used for custom tracking functions", "body": "For an example of how sendRobust is used for sending widget click events, see our documentation on [Tracking with no Anchor](doc:tracking-with-no-anchor)." } [/block] `sendRobust` sends an event to LiftIgniter just like the `send` function. However, it's different from `send` in that it queues the event in a buffer, and sends it on user's new pageview to make sure that the event is sent. This takes care of the case where page redirect happens before sending the click event. The function returns `false` if local storage and cookies are unavailable as a buffer. So if you want to add a small frame of time (let's say for instance, 100 ms), you can consider the following: [block:code] { "codes": [ { "code": "if(!$p(\"sendRobust\",\"widget_click\", {\"clickUrl\":\"url\"})){\n $p(\"send\",\"widget_click\", {\"clickUrl\":\"url\"});\n // event object will be passed from any click listener that you implement.\n // https://developer.mozilla.org/en-US/docs/Web/API/Event\n if (!event.metaKey && !event.shiftKey && event.type == \"click\") {\n event.preventDefault();\n win.setTimeout(function() {\n win.location.href = url;\n }, 100);\n } \n}", "language": "javascript" } ] } [/block]