# CTA (Beta) GTM Tracking

**URL:** <https://community.hubspot.com/t/cta-beta-gtm-tracking/83051>\
**Category:** Blog, Website & Page Publishing\
**Tags:** ctas, forms, professional\
**Created:** [June 9, 2023, 2:23pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051 "2023-06-09T14:23:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_G\_Thompson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ryan_g_thompson/32/38459_2.png) [@Ryan\_G\_Thompson](https://community.hubspot.com/u/Ryan_G_Thompson)\
**Post date:** [June 9, 2023, 2:23pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/1 "2023-06-09T14:23:35Z")

</div>

Hi,

I’ve recently started using the new CTAs (Beta) to replace our existing hubspot marketing pop-up form.

After building the new pop-up, I’m dismayed that it seems completely untrackable in GTM.

I’ve tried using the Hubspot form submission listener and a few other ideas but so far I haven’t been able to push anything into the data layer.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [June 9, 2023, 6:48pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/2 "2023-06-09T18:48:56Z")

</div>

Hello [@Ryan\_G\_Thompson](https://community.hubspot.com/t5/user/viewprofilepage/user-id/179800) Happy Friday!

I want to invite our top experts to this conversation, [@Ben\_M](https://community.hubspot.com/t5/user/viewprofilepage/user-id/87451), and @alyssamwilie any recommendations to [@Ryan\_G\_Thompson](https://community.hubspot.com/t5/user/viewprofilepage/user-id/179800)?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 11, 2023, 3:27pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/3 "2023-06-11T15:27:11Z")

</div>

Hey [@Ryan\_G\_Thompson](https://community.hubspot.com/t5/user/viewprofilepage/user-id/179800) it looks like the new CTA beta uses the class “interactive-button” for it’s buttons, have you tried setting up an event to track clicks based on this class?

---

<div class="post-metadata">

**Author:** ![Ryan\_G\_Thompson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ryan_g_thompson/32/38459_2.png) [@Ryan\_G\_Thompson](https://community.hubspot.com/u/Ryan_G_Thompson)\
**Post date:** [June 13, 2023, 8:30am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/4 "2023-06-13T08:30:33Z")

</div>

Hi Tom, thanks but where does this class occur? On email submission based pop ups like the one I’ve screenshotted I couldn’t locate this class.

 ![Screenshot 2023-06-13 at 4.28.41 pm.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/9/99b2a659e54e27cfa63851873eb6fd5d6b87d3b8.jpeg)

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 13, 2023, 11:23am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/5 "2023-06-13T11:23:17Z")

</div>

Looks like you’re right for the forms, that class I mentioned is just on the button pop-ups. It looks like the submit button on these forms is “hs-form\_\_actions\_\_submit”

---

<div class="post-metadata">

**Author:** ![Ryan\_G\_Thompson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ryan_g_thompson/32/38459_2.png) [@Ryan\_G\_Thompson](https://community.hubspot.com/u/Ryan_G_Thompson)\
**Post date:** [June 18, 2023, 10:26am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/6 "2023-06-18T10:26:23Z")

</div>

No luck Tom, I tried creating this trigger and still nothing happened upon submission.

 ![Ryan_G_Thompson_0-1687083922361.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/f/1fdcd420834e07f59269818ec7f72d3890af5f2a.png)

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 20, 2023, 9:53am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/7 "2023-06-20T09:53:44Z")

</div>

[@Ryan\_G\_Thompson](https://community.hubspot.com/t5/user/viewprofilepage/user-id/179800) it looks like you have double “\_” characters in between the words, is that the case? It should just be one in between each word.

---

<div class="post-metadata">

**Author:** ![Ryan\_G\_Thompson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ryan_g_thompson/32/38459_2.png) [@Ryan\_G\_Thompson](https://community.hubspot.com/u/Ryan_G_Thompson)\
**Post date:** [June 20, 2023, 1:08pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/8 "2023-06-20T13:08:58Z")

</div>

@TomM2 I was following the exact convention you were using above:

> * * *
> 
> @TomM2 wrote:
> 
> It looks like the submit button on these forms is “hs-form\_\_actions\_\_submit”
> 
> * * *

Upon inspecting the element you were indeed correct that the double “\_” characters is used for this button class.

 ![Ryan_G_Thompson_0-1687266235671.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/0/00f162314b090837b2fe13b269353b3aba2f80b9.png)

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 20, 2023, 2:31pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/9 "2023-06-20T14:31:35Z")

</div>

Ah! My apologies! Hmm, that’s about as far as I can think of without having access to the tools to troubleshoot to be honest! I don’t see any reason why GA wouldn’t trigger on these classes.

---

<div class="post-metadata">

**Author:** ![melissachowning](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/melissachowning/32/82797_2.png) [@melissachowning](https://community.hubspot.com/u/melissachowning)\
**Post date:** [June 22, 2023, 12:23am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/10 "2023-06-22T00:23:00Z")

</div>

We’re struggling with this as well and the HubSpot support team hasn’t been able to help us yet either. The first suggested solution referred to injecting an event listener into the iframe, but this does not work if the parent window and iframe are hosted on different domains (which is the case here. iframe domain is [4038620.hs-sites.com](http://4038620.hs-sites.com/)). We think the iframe is the issue. Is there a solution in the works for this?

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 22, 2023, 1:59pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/11 "2023-06-22T13:59:26Z")

</div>

Ah! I didn’t know the new tool is loaded in an iframe, that’s why GA isn’t picking it up then. Unfortunately that would mean it’s not possible to target it with GA. A workaround might be to us custom URLs with UTM parameters as the submission/redirect urls on these ctas [[UA] Collect campaign data with custom URLs [Legacy] - Analytics Help](https://support.google.com/analytics/answer/1033863?hl=en#zippy=%2Cin-this-article)

---

<div class="post-metadata">

**Author:** ![melissachowning](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/melissachowning/32/82797_2.png) [@melissachowning](https://community.hubspot.com/u/melissachowning)\
**Post date:** [June 22, 2023, 2:13pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/12 "2023-06-22T14:13:11Z")

</div>

Unfortunately, that presents an unideal user experience as the reader would be redirected away from the page/content they are reading onto a ‘thank you’ page. The ideal UX is that the user can submit their email and continue reading on the page they are on.

It’s a major bummer with the new CTAs. We want to be able to track traffic source, page, etc., in GA, but it seems at the moment, we cannot.

---

<div class="post-metadata">

**Author:** ![TomM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tomm2/32/70887_2.png) [@TomM2](https://community.hubspot.com/u/TomM2)\
**Post date:** [June 23, 2023, 11:24am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/13 "2023-06-23T11:24:51Z")

</div>

Hi all! I just created a new feature request in the [ideas forum here](https://community.hubspot.com/t5/HubSpot-Ideas/Allow-loading-new-CTAs-Beta-outside-of-iframe/idi-p/811227#M147122)! If this would be useful to you please give it an upvote 🙂

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [June 23, 2023, 6:28pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/14 "2023-06-23T18:28:17Z")

</div>

Thank you for sharing @TomM2 just upvoted!

---

<div class="post-metadata">

**Author:** ![RLeo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rleo/32/9140_2.png) [@RLeo](https://community.hubspot.com/u/RLeo)\
**Post date:** [October 11, 2023, 11:53am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/15 "2023-10-11T11:53:20Z")

</div>

Hello, we are having the same issue aswel. Im trying to listen for the onBeforeSubmit event but as others confirmed, the form is on an Iframe so listening for the events is not possible.  
How can we listen to these events on the new CTAs with forms?

---

<div class="post-metadata">

**Author:** ![sbinkley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sbinkley/32/51304_2.png) [@sbinkley](https://community.hubspot.com/u/sbinkley)\
**Post date:** [June 9, 2024, 6:27pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/16 "2024-06-09T18:27:24Z")

</div>

**Successfully Tracking HubSpot Interactive CTA Buttons with GTM**

Hello everyone,

I wanted to share a solution that worked for me in tracking HubSpot’s new interactive CTA buttons using Google Tag Manager (GTM). I noticed that many of us are struggling with getting these buttons to fire the correct tags, especially since they are dynamically loaded.

After some trial and error, I found that using a MutationObserver to detect these dynamically added elements and attach event listeners to them was effective. Here’s the detailed solution:

1. **Create a Custom HTML Tag in GTM:**
  - Go to the **Tags** section in GTM.
  - Click **New** and select **Tag Configuration**.
  - Choose **Custom HTML**.

2. **Add the Following Script to the Custom HTML Tag:**

```lia-code-sample
<script>
(function() {
 function trackInteractiveButtons() {
 var buttons = document.querySelectorAll('.interactive-button');
 buttons.forEach(function(button) {
 button.addEventListener('click', function() {
 window.dataLayer = window.dataLayer || [];
 window.dataLayer.push({
 event: 'hubspot-button-click',
 'button-class': 'interactive-button',
 'click-url': button.href
 });
 console.log('Interactive button clicked:', button.href);
 });
 });
 }

 // Initial call to track buttons present at page load
 trackInteractiveButtons();

 // MutationObserver to track dynamically added buttons
 var observer = new MutationObserver(function(mutations) {
 mutations.forEach(function(mutation) {
 mutation.addedNodes.forEach(function(node) {
 if (node.nodeType === 1 && node.classList.contains('interactive-button')) {
 node.addEventListener('click', function() {
 window.dataLayer = window.dataLayer || [];
 window.dataLayer.push({
 event: 'hubspot-button-click',
 'button-class': 'interactive-button',
 'click-url': node.href
 });
 console.log('Interactive button clicked:', node.href);
 });
 }
 });
 });
 });

 observer.observe(document.body, {
 childList: true,
 subtree: true
 });
})();
</script>
​

```

- **Set the Trigger for All Clicks:**
  - Attach this Custom HTML tag to trigger on all click; then target “click classes: interactive-button”.

If you have other dynamically loaded elements or different classes, you can adjust the script accordingly. (Such as “hs-image-widget” for the image based CTAs, etc.)

I hope this helps others facing similar issues. Upvote if it worked for you! Happy tracking!

---

<div class="post-metadata">

**Author:** ![sbinkley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sbinkley/32/51304_2.png) [@sbinkley](https://community.hubspot.com/u/sbinkley)\
**Post date:** [June 9, 2024, 6:28pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/17 "2024-06-09T18:28:14Z")

</div>

[@Ryan\_G\_Thompson](https://community.hubspot.com/t5/user/viewprofilepage/user-id/179800) @RLeo @melissachowning

---

<div class="post-metadata">

**Author:** ![Ryan\_G\_Thompson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ryan_g_thompson/32/38459_2.png) [@Ryan\_G\_Thompson](https://community.hubspot.com/u/Ryan_G_Thompson)\
**Post date:** [June 18, 2024, 10:07am UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/18 "2024-06-18T10:07:30Z")

</div>

Hi there,  
I gave this a try but I believe it may only apply to CTA buttons (which I’ve never used). I’ve been using the Pop-up form on Hubspot which still seems untrackable through GTM, although other users have reported having more success using the custom HTML CTA solution.

---

<div class="post-metadata">

**Author:** ![ADantas](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/adantas/32/90766_2.png) [@ADantas](https://community.hubspot.com/u/ADantas)\
**Post date:** [October 9, 2024, 1:49pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/19 "2024-10-09T13:49:54Z")

</div>

hey @sbinkley this looks fantastic.  
I tried to deploy this code, but with no success. Maybe i am missing out on something, would you mind sharing couple of GTM screenshots ? 🙂

---

<div class="post-metadata">

**Author:** ![CMarritt](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cmarritt/32/62359_2.png) [@CMarritt](https://community.hubspot.com/u/CMarritt)\
**Post date:** [January 28, 2025, 9:07pm UTC](https://community.hubspot.com/t/cta-beta-gtm-tracking/83051/20 "2025-01-28T21:07:08Z")

</div>

Hi, this is still an issue today, has anyone had any success?
