Adding InsightEmbed to Your Site
This guide provides platform-specific instructions for adding the InsightEmbed widget to different types of websites. While the basic installation works for most sites, these instructions offer optimized approaches for specific platforms.
Content Management Systems
WordPress
- Log in to your WordPress admin dashboard
- Go to Appearance > Theme Editor
- Select your active theme
- Edit the footer.php file
- Add the InsightEmbed script just before the closing
</body>tag:
html
<script src="https://cdn.insightembed.com/widget.js" data-api-key="YOUR_API_KEY" data-domain="yourdomain.com"></script>- Save the changes
Alternatively, you can use a plugin like "Header and Footer Scripts" to add the code without editing theme files.
Shopify
- From your Shopify admin, go to Online Store > Themes
- Click Actions > Edit code for your active theme
- Under the Layout folder, open the theme.liquid file
- Add the InsightEmbed script just before the closing
</body>tag - Click Save
Wix
- From your Wix dashboard, go to Settings > Custom Code
- Click + Add Custom Code
- Paste the InsightEmbed script
- Set placement to Body - end
- Apply to All pages
- Click Apply
JavaScript Frameworks
React
Create a component for the widget:
jsx
// InsightEmbedWidget.jsx
import { useEffect } from 'react';
const InsightEmbedWidget = ({ apiKey, domain }) => {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://cdn.insightembed.com/widget.js';
script.dataset.apiKey = apiKey;
script.dataset.domain = domain;
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, [apiKey, domain]);
return null;
};
export default InsightEmbedWidget;Then use it in your app:
jsx
// App.jsx
import InsightEmbedWidget from './InsightEmbedWidget';
function App() {
return (
<div className="App">
{/* Your app content */}
<InsightEmbedWidget
apiKey="YOUR_API_KEY"
domain="yourdomain.com"
/>
</div>
);
}Vue.js
Create a component:
vue
<!-- InsightEmbedWidget.vue -->
<template>
<!-- Widget is injected via script -->
</template>
<script>
export default {
name: 'InsightEmbedWidget',
props: {
apiKey: {
type: String,
required: true
},
domain: {
type: String,
required: true
}
},
mounted() {
const script = document.createElement('script');
script.src = 'https://cdn.insightembed.com/widget.js';
script.dataset.apiKey = this.apiKey;
script.dataset.domain = this.domain;
script.async = true;
document.body.appendChild(script);
this.$once('hook:beforeDestroy', () => {
document.body.removeChild(script);
});
}
};
</script>Use it in your app:
vue
<template>
<div id="app">
<!-- Your app content -->
<insight-embed-widget
api-key="YOUR_API_KEY"
domain="yourdomain.com"
/>
</div>
</template>
<script>
import InsightEmbedWidget from './components/InsightEmbedWidget.vue';
export default {
components: {
InsightEmbedWidget
}
};
</script>Angular
Create a service and component:
typescript
// insight-embed.service.ts
import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@Injectable({
providedIn: 'root'
})
export class InsightEmbedService {
constructor(@Inject(DOCUMENT) private document: Document) {}
initialize(apiKey: string, domain: string): void {
const script = this.document.createElement('script');
script.src = 'https://cdn.insightembed.com/widget.js';
script.dataset.apiKey = apiKey;
script.dataset.domain = domain;
script.async = true;
this.document.body.appendChild(script);
}
}typescript
// insight-embed.component.ts
import { Component, OnInit, Input } from '@angular/core';
import { InsightEmbedService } from './insight-embed.service';
@Component({
selector: 'app-insight-embed',
template: ''
})
export class InsightEmbedComponent implements OnInit {
@Input() apiKey!: string;
@Input() domain!: string;
constructor(private insightEmbedService: InsightEmbedService) {}
ngOnInit(): void {
this.insightEmbedService.initialize(this.apiKey, this.domain);
}
}Use it in your app component:
html
<!-- app.component.html -->
<div>
<!-- Your app content -->
<app-insight-embed
apiKey="YOUR_API_KEY"
domain="yourdomain.com"
></app-insight-embed>
</div>Next Steps
After adding the widget to your site:
If you encounter any issues, please refer to our troubleshooting guide or contact our support team at support@insightembed.com.