We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
I struggled a bit to integrate my first HS form in my project. Here's the code I came up with:
<template>
<h1>
HubSportForm
<div id="hubspotForm" v-once></div>
</h1>
</template>
<script>
export default {
mounted() {
const script = document.createElement("script");
script.src="https://js.hsforms.net/forms/v2.js";
document.body.appendChild(script);
script.addEventListener("load", () => {
if (window.hbspt) {
window.hbspt.forms.create({
portalId: "your-portal-id",
formId: "your-form-id",
target: "#hubspotForm"
})
}
})
}
}
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.