APIs & Integrations

Sebbes
Member

U

Hello

I am developper in my compagny and I'd like to connect our single page application to HubSpot. I think the JS API will be the simpler way to do this.

 

I have successfuly "indentified" a user using

_hsq.push(["identify", { email: "mail@domain.com"}])

 and setting page with

_hsq.push(["setPath", "/some-path"])

 Those actions are correctly reflected in the dashboard.

 

However, when I try to add "events", nothing happens. Here is the code I use:

_hsq.push(["trackEvent", {id: "Test event", value:10}]); 

I've tried with and without the value field, it doesnt change anything.

 

What am I doing wrong?

 

The support has already linked me this post: https://community.hubspot.com/t5/APIs-Integrations/Problem-with-Javascript-API-custom-event/td-p/231... but the author of the thread seems to have the same issue than I have and no answer was provided at the end.

 

 

0 Upvotes
3 Replies 3
WendyGoh
HubSpot Employee
HubSpot Employee

U

Hey @Sebbes,

 

In order for me to further troubleshoot this, could you share with me the following:

 

1. The portal ID in question

2. An example page URL

0 Upvotes
Sebbes
Member

U

Here is the portal ID : 6890003

 

Here is an example page: https://hubspot-test-api.github.io/

 

Relevant code is below. As I said, the "identify" and "track page view" things work but not the "trackEvent".

 
    <script type="text/javascript">
        var _hsq = window._hsq = window._hsq || [];
        _hsq.push(['setPath', '/signup']);
        _hsq.push(["identify", {
            email: "sebastien42@gmail.com",
            firstname: "seb",
            lastname: "bes"
        }]);
        _hsq.push(['trackPageView']);
        _hsq.push(['trackEvent', {
            id: "Test event"
        }]);

    </script>
 
0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

U

Hey @Sebbes,

 

Thanks for sharing with me your portal ID and code snippet.

 

I believe I may be able to shed some lights here. 

 

Currently, the Events JavaScript API is only supported on accounts with Marketing Hub Enterprise. Portal 6890003 is on a Marketing Professional subscription, as such the Events JavaScript API wouldn't process.  

0 Upvotes