{"_id":"56a2c4990aefae0d00b7fee4","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"},"__v":9,"parentDoc":null,"user":"56839cf74aecbd0d00a4659e","category":{"_id":"56a2c48a831e2a0d0069b1ad","version":"5668fab608f90021008e8832","__v":5,"project":"5668fab608f90021008e882f","pages":["56a2c4990aefae0d00b7fee4","56a2c4a342dfda0d000463a3","56a2c4bf06150b0d002ad262","56a2c4dd2029df19002b595c","56ec9485406ab51700200633"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-23T00:08:42.770Z","from_sync":false,"order":9,"slug":"debugging","title":"Web Debugging"},"project":"5668fab608f90021008e882f","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-23T00:08:57.061Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"This is a detailed guide to debugging issues with our Javascript and recommendations. It’s meant for recurring issues. For urgent matters, please contact us at [Support](doc:support). For the most part, you shouldn’t need to use this debugging guide at all!\n\nThe detailed instructions here are written for **Google Chrome Developer Tools**, that you can access within the Google Chrome browser. When debugging what’s happening, it’s important to keep Developer Tools open before you load the page. If you have not used Developer Tools before, check out the [Chrome DevTools Overview](https://developer.chrome.com/devtools). Similar debugging can be done using the developer tools of other modern web browsers.\n[block:api-header]\n{\n  \"title\": \"1. Diagnostics\"\n}\n[/block]\nTo diagnose basic issues with the JavaScript SDK, execute [$p(\"runDiagnostics\")](doc:prundiagnostics) in your browser's web console. This should work if the snippet loading LiftIgniter has executed, and the load of our JavaScript file was successful.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. The Network panel\"\n}\n[/block]\nYou can use the Network panel to track all requests made to different domains. You can obtain the request headers, response, and the time taken to execute the request. All requests relevant to LiftIgniter are under the petametrics.com domain. To see only these requests, enter \"petametrics\" (without quotes) in the search bar at the top of the Network panel. To keep your life manageable, type this in before you begin loading the page.\n\nThere are two subdomains to which requests are made:\n<ul>\n<li>cdn.petametrics.com has our Javascript, and is loaded by the Javascript snippet you copy/pasted into the head of your HTML.</li>\n<li>query.petametrics.com receives activities, including pageviews, heartbeat events, and events related to widgets being shown, becoming visible, or getting clicked. It also receives queries for recommendations that you make through the Javascript SDK.</li>\n</ul>\nBoth of these have valid SSL certificates and will load via HTTPS if the user’s current page is being accessed via HTTPS.\n\nThere are a few options that are of particular importance when debugging:\n<ul>\n<li>Selecting the \"Preserve log\" option allows you to preserve information about requests as you navigate between pages. Note that although the request headers and latency information is preserved, the response data is not preserved when you navigate to another page. This should not adversely affect your debugging.</li>\n<li>Selecting the \"Disable cache\" option forces a reload of all resources on every page load, whereas deselecting it allows for resources to be loaded from the browser cache. This is relevant only for fetching our Javascript. API activities and model queries always hit our servers since no two of these are identical.</li>\n</ul>\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b655d1c-li-events.gif\",\n        \"li-events.gif\",\n        1427,\n        734,\n        \"#363636\"\n      ],\n      \"caption\": \"Sequence of petametrics.com events captured in the Chrome Network panel when visiting www.liftigniter.com\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. The Application panel (previously called the Resources panel)\"\n}\n[/block]\nThe Application panel has two sections relevant to LiftIgniter: the \"Local Storage\" and the \"Cookies\" sections. The \"Local Storage\" section is used by us to store some information, including URLs seen and clicked, in hashed form. It is also used to back up some events that need to be sent across different pageviews. It does not work in private browsing mode on Safari but it does work fine in Firefox and Chrome.\n\nIf your site is a mixed HTTP-HTTPS website, then cookies are shared correctly between HTTP and HTTPS, but the local storages are maintained separately.\n\nAll our cookies (with the exception of cookies used to help improve the [Cross-site recommendation](doc:cross-site-recommendation) experience for customers who opt in to it) are stored as first-party cookies under your domain and are accessible under your domain in the Cookies section. LiftIgniter’s cookies are the ones that start with \"_ig\".\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ae93d1a-li-local-storage-and-cookies.gif\",\n        \"li-local-storage-and-cookies.gif\",\n        1427,\n        734,\n        \"#fafaf9\"\n      ],\n      \"caption\": \"Local storage and cookies after a single visit to www.liftigniter.com in an incognito window on Chrome\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. The Elements panel\"\n}\n[/block]\nThe Elements panel allows you to see the fully rendered HTML of your page. You can also edit the HTML and CSS and use this to test simple changes to your website. You can right-click on any element in your webpage and click \"Inspect Element\" to navigate to the HTML of that element in the Elements panel.\n\nThe Elements panel is useful for checking whether you successfully rendered LiftIgniter’s recommendations on your webpage.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/da6bb34-li-elements.gif\",\n        \"li-elements.gif\",\n        1427,\n        734,\n        \"#cacad3\"\n      ],\n      \"caption\": \"Locating the LiftIgniter snippet in the Elements panel of a website (www.liftigniter.com) that uses it.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"5. The Javascript Console panel\"\n}\n[/block]\nThe Javascript Console panel is a good place to check the values of variables and run our Javascript SDK functions for testing, including [$p(\"runDiagnostics\")](doc:prundiagnostics). Our functions are called with \"$p\".\n\nThis panel is also where Javascript execution errors as well as console log statements are stored. Errors appear in red font against a pink background. These could include errors of failure to load scripts, as well as other Javascript errors. Console log statements appear in black against a white background.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"6. The Emulator\"\n}\n[/block]\nChrome’s Developer Tools has an Emulator that allows you to emulate different device types and allows you to throttle network speeds to emulate poorer connectivity. This is particularly helpful if you render your site differently on mobile devices and tablets.\n\nIt is important to keep in mind that the Emulator does not actually emulate different operating systems. It only adjusts the screen size for rendering and the user agent that is communicated to websites. Therefore, rendering details that are specific to some operating systems or devices will not be captured by the Emulator. To test for these, you may need to use a cross-browser testing tool.","excerpt":"","slug":"console-debugging","type":"basic","title":"Console Debugging"}
This is a detailed guide to debugging issues with our Javascript and recommendations. It’s meant for recurring issues. For urgent matters, please contact us at [Support](doc:support). For the most part, you shouldn’t need to use this debugging guide at all! The detailed instructions here are written for **Google Chrome Developer Tools**, that you can access within the Google Chrome browser. When debugging what’s happening, it’s important to keep Developer Tools open before you load the page. If you have not used Developer Tools before, check out the [Chrome DevTools Overview](https://developer.chrome.com/devtools). Similar debugging can be done using the developer tools of other modern web browsers. [block:api-header] { "title": "1. Diagnostics" } [/block] To diagnose basic issues with the JavaScript SDK, execute [$p("runDiagnostics")](doc:prundiagnostics) in your browser's web console. This should work if the snippet loading LiftIgniter has executed, and the load of our JavaScript file was successful. [block:api-header] { "type": "basic", "title": "2. The Network panel" } [/block] You can use the Network panel to track all requests made to different domains. You can obtain the request headers, response, and the time taken to execute the request. All requests relevant to LiftIgniter are under the petametrics.com domain. To see only these requests, enter "petametrics" (without quotes) in the search bar at the top of the Network panel. To keep your life manageable, type this in before you begin loading the page. There are two subdomains to which requests are made: <ul> <li>cdn.petametrics.com has our Javascript, and is loaded by the Javascript snippet you copy/pasted into the head of your HTML.</li> <li>query.petametrics.com receives activities, including pageviews, heartbeat events, and events related to widgets being shown, becoming visible, or getting clicked. It also receives queries for recommendations that you make through the Javascript SDK.</li> </ul> Both of these have valid SSL certificates and will load via HTTPS if the user’s current page is being accessed via HTTPS. There are a few options that are of particular importance when debugging: <ul> <li>Selecting the "Preserve log" option allows you to preserve information about requests as you navigate between pages. Note that although the request headers and latency information is preserved, the response data is not preserved when you navigate to another page. This should not adversely affect your debugging.</li> <li>Selecting the "Disable cache" option forces a reload of all resources on every page load, whereas deselecting it allows for resources to be loaded from the browser cache. This is relevant only for fetching our Javascript. API activities and model queries always hit our servers since no two of these are identical.</li> </ul> [block:image] { "images": [ { "image": [ "https://files.readme.io/b655d1c-li-events.gif", "li-events.gif", 1427, 734, "#363636" ], "caption": "Sequence of petametrics.com events captured in the Chrome Network panel when visiting www.liftigniter.com" } ] } [/block] [block:api-header] { "type": "basic", "title": "3. The Application panel (previously called the Resources panel)" } [/block] The Application panel has two sections relevant to LiftIgniter: the "Local Storage" and the "Cookies" sections. The "Local Storage" section is used by us to store some information, including URLs seen and clicked, in hashed form. It is also used to back up some events that need to be sent across different pageviews. It does not work in private browsing mode on Safari but it does work fine in Firefox and Chrome. If your site is a mixed HTTP-HTTPS website, then cookies are shared correctly between HTTP and HTTPS, but the local storages are maintained separately. All our cookies (with the exception of cookies used to help improve the [Cross-site recommendation](doc:cross-site-recommendation) experience for customers who opt in to it) are stored as first-party cookies under your domain and are accessible under your domain in the Cookies section. LiftIgniter’s cookies are the ones that start with "_ig". [block:image] { "images": [ { "image": [ "https://files.readme.io/ae93d1a-li-local-storage-and-cookies.gif", "li-local-storage-and-cookies.gif", 1427, 734, "#fafaf9" ], "caption": "Local storage and cookies after a single visit to www.liftigniter.com in an incognito window on Chrome" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. The Elements panel" } [/block] The Elements panel allows you to see the fully rendered HTML of your page. You can also edit the HTML and CSS and use this to test simple changes to your website. You can right-click on any element in your webpage and click "Inspect Element" to navigate to the HTML of that element in the Elements panel. The Elements panel is useful for checking whether you successfully rendered LiftIgniter’s recommendations on your webpage. [block:image] { "images": [ { "image": [ "https://files.readme.io/da6bb34-li-elements.gif", "li-elements.gif", 1427, 734, "#cacad3" ], "caption": "Locating the LiftIgniter snippet in the Elements panel of a website (www.liftigniter.com) that uses it." } ] } [/block] [block:api-header] { "type": "basic", "title": "5. The Javascript Console panel" } [/block] The Javascript Console panel is a good place to check the values of variables and run our Javascript SDK functions for testing, including [$p("runDiagnostics")](doc:prundiagnostics). Our functions are called with "$p". This panel is also where Javascript execution errors as well as console log statements are stored. Errors appear in red font against a pink background. These could include errors of failure to load scripts, as well as other Javascript errors. Console log statements appear in black against a white background. [block:api-header] { "type": "basic", "title": "6. The Emulator" } [/block] Chrome’s Developer Tools has an Emulator that allows you to emulate different device types and allows you to throttle network speeds to emulate poorer connectivity. This is particularly helpful if you render your site differently on mobile devices and tablets. It is important to keep in mind that the Emulator does not actually emulate different operating systems. It only adjusts the screen size for rendering and the user agent that is communicated to websites. Therefore, rendering details that are specific to some operating systems or devices will not be captured by the Emulator. To test for these, you may need to use a cross-browser testing tool.