I’m encountering an issue integrating HubSpot CTAs into my Vue.js 3 SPA. The problem is that when the CTA HTML element is placed inside the Vue.js application, HubSpot’s HubSpotCallsToActions.refresh() does not detect or render the CTA properly. However, if I place the same CTA outside the Vue.js app (e.g., directly in the index.html file, outside the Vue-managed <div id=“app”>), the CTA works as expected and is detected by HubSpot without issues.
What I’ve tried:
- Manually calling HubSpotCallsToActions.refresh(): After rendering the Vue component, I made sure to call HubSpotCallsToActions.refresh() in Vue’s onMounted hook. However, it still doesn’t detect the CTA when it’s within the Vue app.
- Using nextTick(): I attempted to use Vue.nextTick() to ensure the DOM was fully rendered before refreshing the CTA, but this didn’t resolve the issue.
- Router-based solutions: Since it’s an SPA, I also tried refreshing the CTAs after route transitions using router.afterEach(). Unfortunately, it didn’t work when the CTA is inside the Vue app
Question:
Has anyone successfully integrated HubSpot CTAs within a Vue.js SPA, and if so, what was your approach to ensure HubSpot correctly detects and refreshes the CTAs?