APIs & Integrations

mohib
Member

Angular 9 project

Looking to integrate the following components into an angular 9 website.
- tracking code (easy..just add to index.html and it works)
- page tracking (seen some examples using js snippets. Is that the only way?)
- form submissions (can hubspot js script automatically pick up angular forms? Or do we need to integrate it via an api call to hubspot?)

0 Upvotes
3 Replies 3
Alex808
Participant

Angular 9 project

Hello mohib!

 

How did you add the `page tracking'. Did you get it right? Any advice will be helpfull.

Below I share my code with you.

I placed it in my index.html, but it does not seem to track pages.

 

<!-- Set up the path for the initial page view -->
<script>
var _hsq = window._hsq = window._hsq || [];
_hsq.push(['setPath', '/']);
</script>

 

<!-- Start of HubSpot Embed Code -->
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/9386841.js"></script>
<!-- End of HubSpot Embed Code -->

 

<!-- Tracking subsequent page views -->
<script>
var _hsq = window._hsq = window._hsq || [];
_hsq.push(['setPath', '/otras-soluciones/anthos']);
_hsq.push(['trackPageView']);
</script>

 

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Angular 9 project

Hey @mohib,

 

Just to clarify,

 

1. What do you mean by page tracking? I'd expect that if the tracking code has been installed correctly and if visitor submit a form submission, the page views will reflect on the contact record.

 

2. As for form, if the Angular form support the requirements for non-HubSpot form, stated here: Use non-HubSpot forms --> Your team will be able to use the non-HubSpot form.

 

However, if the Angular form doesn't meet the requirement, the next best option is to use the Submit data for a form | Forms API.

Alex808
Participant

Angular 9 project

Hello WendyGoh!

Do you know where to place the set page path code in Angular 9 for tracking pages?

I have read this link, but I am not sure if the script of the 'set page path' code should be in the 'index.html' or somewhere else.

https://legacydocs.hubspot.com/docs/methods/tracking_code_api/set_page_path

Any advice would be very helpfull!

0 Upvotes