Triggering a Custom Event via javascript


Hi Collective

I am trying to track successful submission of custom form (that submits/receives success or fail via javascript) using the hubspot events section of reporting. I have read through the forum and do not see why this is not tracking, i can also see the call in the javascript console.

My code is calling: addHUBSpotIdentity($(’#txtIBG_EMAIL’).val(), ‘000002096756’); on success

and the function looks like:

function addHUBSpotIdentity(emailAddress, eventName) {
    try {
        var _hsq = window._hsq = window._hsq || [];
            email: emailAddress

        //analytics.identify(emailAddress, {
        //    email: emailAddress

        _hsq.push(["trackEvent", {
            id: eventName,
            value: 'success'
    } catch (e) {

and has been tried with and without the optional value parameter. This javascript is embeded into our hubspot custom module on one of our key landing pages.

Can anyone see what is wrong here?



@fairtrades Are you seeing an error? Is the function being called with the right parameters? Does your ID match the one you made in HubSpot?


Hi Mate

thanks for the thoughts, the function is definatly getting the right parameters, and the event ID is correct, however the problem has a slight twist, after leaving it in the live code over the weekend, i noticed that i am now seeing 189 completions but no customers/contacts registered against the event stats. So i dont think the code to identify is being useful, my understanding was that causing a track event after pushing identify would enable hubspot to well identify the user.

Further i have proven that their is a time delay (maybe even nightly) between event being logged on form completion and event being shown on the reporting->events statistics.


@fairtrades beyond the delay, is their still a problem with the association? Does the contact exist of what you are logging the event for?


still zero contacts associated with the event, the contact doesn’t exist at the point of form submission however it is created via the API when the submit to our service happens, so roughly around the same time, i was expecting the identify to create a contact though, any idea if this is what should happen?


@fairtrades For the contact to get created you would have to push the identity before the tracking code is loaded and launched. If it is after that then it wouldn’t be able to tie the identity to the utk.