• Créditos da HubSpot: Desbloqueie ferramentas poderosas para o crescimento

    Dúvidas?

Custom Behavioral Event is showing completions before I deployed the code to the prod site.

WMusgrove
Membro

Hey!

 

I created a custom behavioral event called "Email Capture".

 

Hubspot gave me a code snippet like this to execute on my site whenever a user performs this action.

 

```

var _hsq = window._hsq = window._hsq || [];
    _hsq.push([
      'trackCustomBehavioralEvent',
      {
        name: 'pe123456789_email_capture',
        properties: {
          // this is optional and you don't have to put anything here
          // give each property a value so we know what they mean
          options
        },
      },
    ]);

```

However I have not deployed this code to my production site yet.  It's only on my local site.  But I'm seeing thousands of "completions" ever since I created this custom behavioral event in the hubspot UI under Reports > Analytics Tools > Custom Behavioral Events.  Why is this event reporting completions when I haven't deployed my custom usage of this code snippet to the prod site yet?

 

WMusgrove_0-1675870915430.png

 

0 Avaliação positiva
3 Respostas 3
WMusgrove
Membro

Oh it's because when I added that script is wrapped it in a `if (true)` so it fires on every page hit.  Why?  I didn't know it would do that.  How do I make that stop so I can only fire this event from meaningful places in my custom code?

 

```

// 'true' tracks this event on every page view
if (true) {
_hsq.push([
'trackCustomBehavioralEvent',
{
name: 'pe123456789_email_capture',
properties: {
// give each property a value so we know what they mean
},
},
]);
}

```

0 Avaliação positiva
gavin667
Participante

I was having the same issue and I managed to get this to not fire by removing all the code in that snippet and firing it manually within my application or via GTM. There is a message below the code box but it isn't clear in my opinion and sounds like if you you remove this code the event won't be valid and any manual attempt won't work.

Also... annoyingly if you remove all the code from the code block you can't hit the "Done" button on the editor. Something has to be in the box to get the "Done" button to be clickable. I just added a space. I guess a comment would also work.

 

Screenshot 2023-04-16 at 20.15.40.png

0 Avaliação positiva
WMusgrove
Membro

Do I choose this option instead, but still use the javascript snippet in my custom code to provide the `pe123456789_email_capture` event?

 

WMusgrove_0-1675871511895.png

 

0 Avaliação positiva