
Security Fundamentals
Turtles, Clams, and Cyber Threat Actors: Shell Usage
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
react-hubspot-tracking-code-hook
Advanced tools
The HubSpot tracking code function as a hook to use in your React project (SPA) with all the functions available in the HubSpot Tracking code API documentation.
A custom hook to use the HubSpot Tracking Code API function.
With this custom hook, you can easily use the HubSpot Tracking Code API function.
First step, install the HubSpot tracking code in your React project following the HubSpot documentation about it.
Tip: You can copy and paste the script code directly in the public/index.html
file or use the Google Tag Manager to install as a pixel.
then,
$ yarn add react-hubspot-tracking-code-hook
# or
$ npm install react-hubspot-tracking-code-hook
This library is using the global function window._hsq
that's initialized from HubSpot tracking code.
import React from "react";
import { useTrackingCode } from "react-hubspot-tracking-code-hook";
const App = () => {
const { setPathPageView, setIdentity } = useTrackingCode();
setPathPageView("/home");
setIdentity("your-email@provider.com");
setContentType("landing-page");
return <div>My app</div>;
};
useTrackingCode
provides the functions from HubSpot tracking code;
Names | Params | Required | Info |
---|---|---|---|
setContentType | contentType: string | x | Additional code to bucket data into HubSpot page types (standard-page, site-page, landing-page, listing-page, blog-post, or knowledge-article) |
setPathPageView | pathName: string | YES | Set the path to the current page will be treated. This function should be used to update the current page whenever a page is loaded. After using this function to update the path, it will call the setTrackPageView function to track the view of the current page. |
setTrackPageView | x | x | This function is called when the tracking code is loaded on a page, but you can manually call this function to track subsequent views in a single page application. |
setIdentity | (email: string, otherProperties: object) | email: YES | This function is used to identify a visitor to your site. The unique identifier is an email address. If there is an existing contact record for that email address, it will be updated. Otherwise, a new contact record will be created. In both cases, the analytics data collected for the visitor will be associated with the contact record. |
setTrackEvent | ({ eventId: string, value: string or number }) | eventId: YES | This function is used to track an event using JavaScript and HubSpot's tracking code. You can use events to track specific activities completed by visitors on your site. Tracked events can show up in contacts' timelines. |
react-hubspot-tracking-code-hook
is under MIT License
Thanks goes to these wonderful people (emoji key):
Kelvin Maues 📖 💻 | Logan Koester 💻 📖 | Kyle Hotchkiss 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
The HubSpot tracking code function as a hook to use in your React project (SPA) with all the functions available in the HubSpot Tracking code API documentation.
The npm package react-hubspot-tracking-code-hook receives a total of 5,273 weekly downloads. As such, react-hubspot-tracking-code-hook popularity was classified as popular.
We found that react-hubspot-tracking-code-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.