{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Single Page Application","type":"basic","slug":"push-state-based-single-page-application","excerpt":"","body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Hash routing or PushState based Single Page Application\"\n}\n[/block]\nIf you are using pushState API of HTML5, or using a simple hash routing for Single Page Applications (we will call this type of SPA a `Simple Single Page Application`), we provide a setting on our SDK so that it could track users transitioning to a new page.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// You can reference other custom configurations on $p(\\\"init\\\") documentation. \\nvar customConfig = {\\n\\tconfig: {\\n  \\tsdk: {\\n    \\tpushStateReset: true\\n    }\\n  }\\n}\\n$p(\\\"init\\\",\\\"JS_KEY\\\",customConfig)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nSetting this to true will reset our client to a status of initial pageview after the url hash is changed, or `history.pushState` function is invoked.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Other Implementations\"\n}\n[/block]\nIf your Single Page Application has a heavily customized user flow (non-Simple), then most of Single Page Application Integration is about directly invoking things such as cookie update or pageview since our script won't be loaded/initialized between \"page\" transition.\n\n`$p` functions documented in this section will help you in sending activities and querying recommendations to LiftIgniter.","updates":[],"order":1,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"574ff8093fa1870e00889bbf","user":"5668fa9755e4b32100935d41","category":{"sync":{"isSync":false,"url":""},"pages":["56975be30b09a41900b24494","56a15cfd470ae00d00c3061f","56e356004dc30f0e0051b3ed"],"title":"JavaScript SDK","slug":"javascript-sdk","order":2,"from_sync":false,"reference":true,"_id":"569743020b09a41900b2446d","__v":3,"createdAt":"2016-01-14T06:41:06.893Z","project":"5668fab608f90021008e882f","version":"5668fab608f90021008e8832"},"createdAt":"2016-06-02T09:10:33.219Z","parentDoc":null,"__v":25,"githubsync":"","version":{"version":"1.18","version_clean":"1.18.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5668fab708f90021008e8833","569740f124490c3700170a64","569742b58560a60d00e2c25d","569742bd0b09a41900b2446c","569742cd69393517000c82b3","569742f459a6692d003fad8f","569743020b09a41900b2446d","5697430b69393517000c82b5","56a17776470ae00d00c30642","56a2c48a831e2a0d0069b1ad","56b535757bccae0d00e9a1cd","56e1ff6aa49fdc0e005746b5","57e1c88115bf6522002a5e4e","57fa65275ba65a17008b988f","57fbeea34002550e004c032e","58474584889b6c2d00fb86e9","58475dcc64157f0f002f1907","587e7b5158666c2700965d4e","58a349fc30852819007ba083"],"_id":"5668fab608f90021008e8832","__v":19,"releaseDate":"2015-12-10T04:08:22.769Z","createdAt":"2015-12-10T04:08:22.769Z","project":"5668fab608f90021008e882f"},"project":"5668fab608f90021008e882f"}

Single Page Application


[block:api-header] { "type": "basic", "title": "Hash routing or PushState based Single Page Application" } [/block] If you are using pushState API of HTML5, or using a simple hash routing for Single Page Applications (we will call this type of SPA a `Simple Single Page Application`), we provide a setting on our SDK so that it could track users transitioning to a new page. [block:code] { "codes": [ { "code": "// You can reference other custom configurations on $p(\"init\") documentation. \nvar customConfig = {\n\tconfig: {\n \tsdk: {\n \tpushStateReset: true\n }\n }\n}\n$p(\"init\",\"JS_KEY\",customConfig)", "language": "javascript" } ] } [/block] Setting this to true will reset our client to a status of initial pageview after the url hash is changed, or `history.pushState` function is invoked. [block:api-header] { "type": "basic", "title": "Other Implementations" } [/block] If your Single Page Application has a heavily customized user flow (non-Simple), then most of Single Page Application Integration is about directly invoking things such as cookie update or pageview since our script won't be loaded/initialized between "page" transition. `$p` functions documented in this section will help you in sending activities and querying recommendations to LiftIgniter.