{"schemaVersion":1,"title":"JavaScript embed setup","url":"https://appgram.dev/docs/guides/sdks/embed","markdownUrl":"https://appgram.dev/docs/format-md/guides/sdks/embed.md","jsonUrl":"https://appgram.dev/docs/agent/pages/guides/sdks/embed.json","version":"current","locale":"en","markdown":"# JavaScript embed setup\n\nAdd floating or inline widgets to any website.\n\nUse the JavaScript embed to add AppGram to a website without installing a framework package. The script runs in the browser and loads your project's portal in a widget.\n\n## Add a floating widget\n\nPlace this in your page and replace the project ID. A public `organization-slug/project-slug` project key is also supported.\n\n```html\n<script\n  src=\"https://cdn.appgram.dev/appgram.min.js\"\n  data-project=\"YOUR_PROJECT_ID\"\n></script>\n```\n\nThe script initializes from `data-project`. Load it once per page. A management API key is not part of embed configuration.\n\nFor a complete `index.html` page and local-server command, follow [Show feedback in your application](/guides/getting-started#5-show-feedback-in-your-application). Create and approve the walkthrough's sample request first, then cast a vote in the widget and confirm the saved count in the dashboard.\n\n## Inline mode\n\nCreate the container before loading the script. Define settings before the script tag:\n\n```html\n<div id=\"appgram-feedback\" style=\"height: 600px\"></div>\n<script>\n  window.appgramSettings = {\n    projectKey: 'YOUR_PROJECT_ID',\n    mode: 'inline',\n    container: '#appgram-feedback',\n    defaultPage: 'feedback',\n  };\n</script>\n<script src=\"https://cdn.appgram.dev/appgram.min.js\"></script>\n```\n\nThe widget needs an existing container with visible dimensions. If your site uses a strict Content Security Policy, authorize the script and the portal iframe origin your project uses; an inline settings script also needs your application's approved nonce or hash.\n\n## Open a page from your own button\n\nAfter the script has loaded and initialized:\n\n```javascript\nwindow.AppGram.open('feedback');\nwindow.AppGram.close();\n```\n\nDo not call these methods from a script that runs before the external SDK has loaded. For a custom initialization flow, use the documented `onReady` callback and instance API.\n\n## Customer context and cleanup\n\nThe embed supports `user` in its initial settings and `setUser` for an active customer. For single-page applications, tear down the widget with `destroy()` when its owning screen is removed. Treat account changes and sign-out as a widget lifecycle change; do not assume passing an empty user object clears previous identity.\n\nContinue with the [embed reference](/embed-sdk), [customer identity guide](/guides/client-identity), and [troubleshooting guide](/guides/troubleshooting).\n\n","contentLocale":"en","isFallback":false,"authorship":{"authors":[],"contributors":[],"reviewedBy":[]}}