And further on it says: The data will only be passed when tracking a pageview or an event (with either the trackPageViewor trackEvent functions).
So I tried to create a custom event, below is the complete code:
Useremail is logged in user, which exists in hubspot and Craft):
var _hsq = _hsq || [];
_hsq.push([“identify”,{
email: useremail,
}]);
// Update to 'true' if you want to track event on every page view
if (true) {
_hsq.push(["trackEvent", {
id: "000002638763",
email: useremail,
}]);
}
Can you tell me if what I’m trying to do is correct, to identify logged in user and track this user in our webpage?
Nothing is logged on the user, but the custom event has a completion registered on it (but no contacts).
Also I’m testing locally where localhost is given a domain name and I can see visited urls in my hubspot test account (completions), but no contact activity.
Hello,
I have the same issue…
I try several _hsq.push and there is no activity logged in the user page on hubspot :
_hsq.push([“identify”,{ email: ‘<%= current_user.email %>’ }]);
_hsq.push([‘trackEvent’,{ email: ‘<%= current_user.email %>’ }]);
_hsq.push([“trackPageView”, {email: ‘<%= current_user.email %>’}]);
I’m testing locally…
Is there a delay to have the activity information on the user page or should it be instant ?
@eirin Do you know who you were talking to internally? I’m not aware of any issues testing locally to run the tracking code and fire off an event. Can you paste your current code in here again so I can see if it looks correct to me or not?
It’s just for test. I need to change it, but I thought I should see an event happening on the correct contact before I spent time on handling the logic for when it should happen. I also need to move the code because now it’s happening each time the page is loaded if the user is logged in. The code you’re referring to is fetched from hubspot page.
Could the problem be that I’m testing internally using a domain for localhost?
@eirin I don’t think testing it locally is the issue. It will run every time until you make a different condition in your if statement. since right not it will always result to true it will run every time.
Yes, It was just someone else in your organization mentioned that hubspot did not allow for localhost testing (as domain). But does the code look correct to you? Could it be something with the event I configured?