Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@piwikpro/react-piwik-pro
Advanced tools
Dedicated Piwik PRO library that helps with implementing Piwik PRO Tag Manager and the Piwik PRO tracking client in React applications.
To use this package in your project, run the following command.
npm install @piwikpro/react-piwik-pro
In your React Project, include the default PiwikPro
in the highest level application module. ie index
. To set up the Piwik PRO Tag Manager container in the app, the easiest way is to call the PiwikPro.initialize()
method. PiwikPro.initialize()
must be initialized using this function before any of the other tracking functions will record any data.
In the arguments, pass your app ID and your account URL as parameters (marked 'container-id' and 'container-url' in the example below).
import PiwikPro from '@piwikpro/react-piwik-pro';
PiwikPro.initialize('container-id', 'container-url');
ReactDOM.render(<App />, document.getElementById('root'))
The nonce attribute is useful to allow-list specific elements, such as a particular inline script or style elements. It can help you to avoid using the CSP unsafe-inline directive, which would allow-list all inline scripts or styles.
If you want your nonce to be passed to the script, pass it as the third argument when calling the script initialization method.
import PiwikPro from '@piwikpro/react-piwik-pro';
PiwikPro.initialize('container-id', 'container-url', 'nonce-string');
ReactDOM.render(<App />, document.getElementById('root'))
import { CustomEvent } from '@piwikpro/react-piwik-pro'
export class TestFormComponent {
onUserInputName() {
...
CustomEvent.trackEvent('user_register_form', 'enter_name', 'Name', 'Value');
}
onUserInputEmail() {
...
CustomEvent.trackEvent('user_register_form', 'enter_email', 'Email', 'Value');
}
onSubmit() {
...
CustomEvent.trackEvent('user_register_form', 'submit', 'Sent');
}
}
import { PageViews } from '@piwikpro/react-piwik-pro';
...
const App = () => {
PageViews.trackPageView('optional title');
return ...;
}
export default App
import { DataLayer } from '@piwikpro/react-piwik-pro';
...
const App = () => {
DataLayer.push({ event: 'test-event' });
return ...;
}
export default App
import PiwikPro from '@piwikpro/react-piwik-pro';
A page view is the most basic type of a tracked event. It represents a single page viewing action.
import { PageViews } from '@piwikpro/react-piwik-pro'
trackPageView(customPageTitle?: string)
- Tracks a visit on the page that the function was run on.import { UserManagement } from '@piwikpro/react-piwik-pro'
getUserId()
- The function that will return user ID.setUserId(userId: string)
- user ID is an additional parameter that allows you to aggregate data. When set up, you will be able to search through sessions by this parameter, filter reports through it or create Multi attribution reports using User ID.resetUserId()
- Clears previously set userID
, e.g. when visitor logs out.getVisitorId()
- Returns 16-character hex ID of the visitor.getVisitorInfo()
- Returns visitor information in an array:
Custom events enable tracking visitor actions that are not predefined in the existing JavaScript Tracking Client API, allowing web analysts to accurately measure and analyze any domain.
import { CustomEvent } from '@piwikpro/react-piwik-pro'
trackEvent(category: string, action: string, name?: string, value?: number)
- Tracks a custom event, e.g. when a visitor interacts with the page.Site search tracking gives you insights into how visitors interact with the search engine on your website - what they search for and how many results they get back.
import { SiteSearch } from '@piwikpro/react-piwik-pro'
trackSiteSearch(keyword: string, category?: string, searchCount?: number, dimensions?: Object)
- Tracks search requests on a website.import { eCommerce } from '@piwikpro/react-piwik-pro'
ecommerceAddToCart(products: Product[])
- Tracks action of adding products to a cart.ecommerceRemoveFromCart(products: Product[])
- Tracks action of removing a products from a cart.ecommerceOrder(products: Product[], paymentInformation: PaymentInformation)
- Tracks conversion (including products and payment details).ecommerceCartUpdate(products: Product[], grandTotal: PaymentInformation['grandTotal'])
- Tracks current state of a cart.ecommerceProductDetailView(products: Product[])
- Tracks product or category view. Must be followed by a page view.Content Tracking lets you track what content is visible on your site and how users interact with it.
import { ContentTracking } from '@piwikpro/react-piwik-pro'
trackContentImpression(contentName: string, contentPiece: string, contentTarget: string)
- Tracks manual content impression event.trackContentInteraction(contentInteraction: string, contentName: string, contentPiece: string, contentTarget: string)
- Tracks manual content interaction event.import { DownloadAndOutlink } from '@piwikpro/react-piwik-pro'
trackLink(url: string, linkType: string, customData?: object, callback?: (params: any) => void)
- Manually tracks outlink or download event with provided values.enableLinkTracking(enable: boolean)
- Enables or disables automatic link tracking. If enabled, left, right and middle clicks on links will be treated as opening a link. Opening a links to an external site (different domain) creates an outlink event. Opening a link to a downloadable file creates a download event.setLinkClasses(classes: string[])
- Sets a list of class names that indicate whether a link is an outlink and not download.setDownloadClasses(classes: string[])
- Sets a list of class names that indicate whether a list is a download and not an outlink.setDownloadExtensions(extensions: string[])
- Overwrites the list of file extensions indicating that a link is a download.addDownloadExtensions(extensions: string[])
- Adds new extensions to the download extensions list.removeDownloadExtensions(extensions: string[])
- Removes extensions from the download extensions list.setLinkTrackingTimer(time: number)
- When a visitor produces an events and closes the page immediately afterwards, e.g. when opening a link, the request might get cancelled. To avoid loosing the last event this way, JavaScript Tracking Client will lock the page for a fraction of a second (if wait time hasn’t passed), giving the request time to reach the Collecting & Processing Pipeline.getLinkTrackingTimer()
- Returns lock/wait time after a request set by setLinkTrackingTimer.setIgnoreClasses(classes: string[])
- Set a list of class names that indicate a link should not be tracked.Goals let you define important actions registered in your application and track conversions when the conditions for the action are fulfilled.
import { GoalConversions } from '@piwikpro/react-piwik-pro'
trackGoal(goalId: number | string, conversionValue: number, dimensions?: Object)
- Tracks manual goal conversion.import { CustomDimensions } from '@piwikpro/react-piwik-pro'
setCustomDimensionValue(customDimensionId: string | number, customDimensionValue: string)
- Sets a custom dimension value to be used later.deleteCustomDimension(customDimensionId: string)
- Removes a custom dimension with the specified ID.getCustomDimensionValue(customDimensionId: string | number)
- Returns the value of a custom dimension with the specified ID.A data layer is a data structure on your site or app where you can store data and access it with tools like Tag Manager. You can include any data you want in your data layer.
import { DataLayer } from '@piwikpro/react-piwik-pro';
push(dataLayerObject: Object)
- Adds an event to a data layer.FAQs
Piwik PRO tracking library for ReactJS
We found that @piwikpro/react-piwik-pro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.