Skip to main content

How do I make sure BugHerd shows pins on the correct screen in a single-page web app (SPA)?

If pins appear on the wrong screen in your SPA, set or update window.BugHerdConfig.location to tell BugHerd the correct page URL.

Richard O'Brien avatar
Written by Richard O'Brien
Updated over 3 weeks ago

In single-page web apps (SPAs), the URL doesn’t always change when users navigate between different views. Because BugHerd uses the page URL to know where pins belong, this can sometimes cause pins from different screens to appear together.

To fix this, you can tell BugHerd the correct page location by setting the window.BugHerdConfig.location value.

Step 1: Set the location when you embed BugHerd

Add the following snippet when you install BugHerd on your site:

<script type="text/javascript"
src="https://www.bugherd.com/sidebarv2.js?apikey=YOUR-API-KEY-HERE" async="true" ></script>
<script>
var BugHerdConfig = {
location: new URL('https://yoursite.com/example')
};
</script>

Step 2: Update the location when your app view changes

If your app’s content changes without a URL change, update the location dynamically:

window.BugHerdConfig.location = new URL('https://yoursite.com/example/settings');

Any new feedback created after this update will be correctly associated with that “page.”

You don’t need to reload the page or re-initialize BugHerd, just update the location value when your app view changes.

Did this answer your question?