Vue
Initialize in mounted and trigger from methods
Initialize in authenticated views only
Do not initialize the widget in your root App.vue or public pages. Use it in a component that only renders for logged-in users (e.g., a dashboard view or member area).
<template>
<button @click="openFeedback">Leave a Review</button>
</template>
<script>
export default {
mounted() {
if (typeof window !== 'undefined' && window.TheWebRatings) {
window.TheWebRatings.init({ apiKey: 'your-api-key' });
}
},
methods: {
openFeedback() {
// Replace with your logged-in user (e.g. from auth store)
window.TheWebRatings?.open('[email protected]', 'User Name');
}
}
}
</script>Ensure the widget script is loaded in your authenticated layout (not your public index.html). For SSR, guard window access.