diff --git a/README.md b/README.md index 94f125c..0dd3af2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ - # Piwik PRO Library for React Dedicated Piwik PRO library that helps with implementing Piwik PRO Tag Manager and the Piwik PRO tracking client in React applications. @@ -114,1145 +113,1291 @@ export default App ``` - - - - -### Table of contents - -#### Namespaces - -- [ClientConfiguration](#modulesclientconfigurationmd) -- [ContentTracking](#modulescontenttrackingmd) -- [CookieManagement](#modulescookiemanagementmd) -- [CrossDomainTracking](#modulescrossdomaintrackingmd) -- [CustomDimensions](#modulescustomdimensionsmd) -- [CustomEvent](#modulescustomeventmd) -- [DataLayer](#modulesdatalayermd) -- [DownloadAndOutlink](#modulesdownloadandoutlinkmd) -- [ErrorTracking](#moduleserrortrackingmd) -- [GoalConversions](#modulesgoalconversionsmd) -- [Heartbeat](#modulesheartbeatmd) -- [Miscellaneous](#modulesmiscellaneousmd) -- [PageViews](#modulespageviewsmd) -- [SiteSearch](#modulessitesearchmd) -- [UserManagement](#modulesusermanagementmd) -- [eCommerce](#modulesecommercemd) - -#### Type Aliases - -- [Dimensions](#dimensions) -- [EcommerceOptions](#ecommerceoptions) -- [GetInitScript](#getinitscript) -- [InitOptions](#initoptions) -- [Initialize](#initialize) -- [PaymentInformation](#paymentinformation) -- [Product](#product) -- [VisitorInfo](#visitorinfo) - -#### Variables - -- [default](#default) - -### Type Aliases - -#### Dimensions + -Ƭ **Dimensions**: `Record`\<\`dimension$\{number}\`, `string`\> -___ +*** -#### EcommerceOptions -Ƭ **EcommerceOptions**: `Object` -##### Type declaration +### Table of contents -| Name | Type | Description | -| :------ | :------ | :------ | -| `currencyCode?` | `string` | Currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format. If not provided, the currency set in app settings will be used instead. | +- [ClientConfiguration](#namespacesclientconfigurationreadmemd) +- [ContentTracking](#namespacescontenttrackingreadmemd) +- [CookieManagement](#namespacescookiemanagementreadmemd) +- [CrossDomainTracking](#namespacescrossdomaintrackingreadmemd) +- [CustomDimensions](#namespacescustomdimensionsreadmemd) +- [CustomEvent](#namespacescustomeventreadmemd) +- [DataLayer](#namespacesdatalayerreadmemd) +- [DownloadAndOutlink](#namespacesdownloadandoutlinkreadmemd) +- [eCommerce](#namespacesecommercereadmemd) +- [ErrorTracking](#namespaceserrortrackingreadmemd) +- [GoalConversions](#namespacesgoalconversionsreadmemd) +- [Heartbeat](#namespacesheartbeatreadmemd) +- [Miscellaneous](#namespacesmiscellaneousreadmemd) +- [PageViews](#namespacespageviewsreadmemd) +- [SiteSearch](#namespacessitesearchreadmemd) +- [UserManagement](#namespacesusermanagementreadmemd) -___ +### Type Aliases -#### GetInitScript +- [Dimensions](#type-aliasesdimensionsmd) +- [EcommerceOptions](#type-aliasesecommerceoptionsmd) +- [GetInitScript](#type-aliasesgetinitscriptmd) +- [Initialize](#type-aliasesinitializemd) +- [InitOptions](#type-aliasesinitoptionsmd) +- [PaymentInformation](#type-aliasespaymentinformationmd) +- [Product](#type-aliasesproductmd) +- [VisitorInfo](#type-aliasesvisitorinfomd) -Ƭ **GetInitScript**: (`params`: `GetInitScriptParams`) => `string` +### Variables -##### Type declaration +- [default](#variablesdefaultmd) -▸ (`params`): `string` -###### Parameters + -| Name | Type | -| :------ | :------ | -| `params` | `GetInitScriptParams` | -###### Returns +*** -`string` -___ +## ClientConfiguration -#### InitOptions -Ƭ **InitOptions**: `Object` +- [getDomains](#namespacesclientconfigurationfunctionsgetdomainsmd) +- [setDomains](#namespacesclientconfigurationfunctionssetdomainsmd) -##### Type declaration -| Name | Type | Description | -| :------ | :------ | :------ | -| `dataLayerName?` | `string` | Defaults to 'dataLayer' | -| `nonce?` | `string` | - | + -___ -#### Initialize +*** -Ƭ **Initialize**: (`containerId`: `string`, `containerUrl`: `string`, `nonceOrOptions?`: `string` \| [`InitOptions`](#initoptions)) => `void` -##### Type declaration +## getDomains() -▸ (`containerId`, `containerUrl`, `nonceOrOptions?`): `void` +> **getDomains**(): `Promise`\<`string`[]\> -###### Parameters +Returns list of internal domains (set with "setDomains" function and used in outlink tracking). -| Name | Type | -| :------ | :------ | -| `containerId` | `string` | -| `containerUrl` | `string` | -| `nonceOrOptions?` | `string` \| [`InitOptions`](#initoptions) | +### Returns -###### Returns +`Promise`\<`string`[]\> -`void` -___ + -#### PaymentInformation -Ƭ **PaymentInformation**: `Object` +*** -##### Type declaration -| Name | Type | -| :------ | :------ | -| `discount?` | `number` \| `string` | -| `grandTotal` | `number` \| `string` | -| `orderId` | `string` | -| `shipping?` | `number` \| `string` | -| `subTotal?` | `number` \| `string` | -| `tax?` | `number` \| `string` | +## setDomains() -___ +> **setDomains**(`domains`): `void` -#### Product +Allows to define a list of internal domains or mobile app URIs. Used in outlink tracking for determining whether a link is an outlink and in cross domain linking for determining which links should have visitor ID parameter injected. -Ƭ **Product**: `Object` +### Parameters -##### Type declaration +| Parameter | Type | +| ------ | ------ | +| `domains` | `string`[] | -| Name | Type | -| :------ | :------ | -| `brand?` | `string` | -| `category?` | `LimitedArrayFiveStrings` | -| `customDimensions?` | `Record`\<`number`, `string`\> | -| `name?` | `string` | -| `price?` | `number` | -| `quantity?` | `number` | -| `sku` | `string` | -| `variant?` | `string` | +### Returns -___ +`void` -#### VisitorInfo -Ƭ **VisitorInfo**: [isNew: "0" \| "1", visitorId: string, firstVisitTS: number, previousVisitCount: string \| number, currentVisitTS: number, lastVisitTS: number \| "", lastEcommerceOrderTS: number \| ""] + -### Variables -#### default +*** -• **default**: `Object` -##### Type declaration +## ContentTracking -| Name | Type | -| :------ | :------ | -| `getInitScript` | [`GetInitScript`](#getinitscript) | -| `initialize` | [`Initialize`](#initialize) | +- [logAllContentBlocksOnPage](#namespacescontenttrackingfunctionslogallcontentblocksonpagemd) +- [trackAllContentImpressions](#namespacescontenttrackingfunctionstrackallcontentimpressionsmd) +- [trackContentImpression](#namespacescontenttrackingfunctionstrackcontentimpressionmd) +- [trackContentImpressionsWithinNode](#namespacescontenttrackingfunctionstrackcontentimpressionswithinnodemd) +- [trackContentInteraction](#namespacescontenttrackingfunctionstrackcontentinteractionmd) +- [trackContentInteractionNode](#namespacescontenttrackingfunctionstrackcontentinteractionnodemd) +- [trackVisibleContentImpressions](#namespacescontenttrackingfunctionstrackvisiblecontentimpressionsmd) - + -## ClientConfiguration -### Table of contents +*** -- [getDomains](#getdomains) -- [setDomains](#setdomains) +## logAllContentBlocksOnPage() +> **logAllContentBlocksOnPage**(): `void` -#### getDomains +Print all content blocks to the console for debugging purposes -▸ **getDomains**(): `Promise`\<`string`[]\> +### Returns -Returns list of internal domains (set with "setDomains" function and used in outlink tracking). +`void` -##### Returns -`Promise`\<`string`[]\> + -___ -#### setDomains +*** -▸ **setDomains**(`domains`): `void` -Allows to define a list of internal domains or mobile app URIs. Used in outlink tracking for determining whether a link is an outlink and in cross domain linking for determining which links should have visitor ID parameter injected. +## trackAllContentImpressions() -##### Parameters +> **trackAllContentImpressions**(): `void` -| Name | Type | -| :------ | :------ | -| `domains` | `string`[] | +Scans the entire DOM for content blocks and tracks impressions after all page +elements load. It does not send duplicates on repeated calls unless +trackPageView was called in between trackAllContentImpressions invocations -##### Returns +### Returns `void` - - - -## ContentTracking + -### Table of contents +*** -- [logAllContentBlocksOnPage](#logallcontentblocksonpage) -- [trackAllContentImpressions](#trackallcontentimpressions) -- [trackContentImpression](#trackcontentimpression) -- [trackContentImpressionsWithinNode](#trackcontentimpressionswithinnode) -- [trackContentInteraction](#trackcontentinteraction) -- [trackContentInteractionNode](#trackcontentinteractionnode) -- [trackVisibleContentImpressions](#trackvisiblecontentimpressions) +## trackContentImpression() -#### logAllContentBlocksOnPage +> **trackContentImpression**(`contentName`, `contentPiece`, `contentTarget`): `void` -▸ **logAllContentBlocksOnPage**(): `void` +### Parameters -Print all content blocks to the console for debugging purposes +| Parameter | Type | +| ------ | ------ | +| `contentName` | `string` | +| `contentPiece` | `string` | +| `contentTarget` | `string` | -##### Returns +### Returns `void` -___ - -#### trackAllContentImpressions - -▸ **trackAllContentImpressions**(): `void` -Scans the entire DOM for content blocks and tracks impressions after all page -elements load. It does not send duplicates on repeated calls unless -trackPageView was called in between trackAllContentImpressions invocations + -##### Returns -`void` +*** -___ -#### trackContentImpression +## trackContentImpressionsWithinNode() -▸ **trackContentImpression**(`contentName`, `contentPiece`, `contentTarget`): `void` +> **trackContentImpressionsWithinNode**(`domNode`): `void` -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `contentName` | `string` | -| `contentPiece` | `string` | -| `contentTarget` | `string` | +| Parameter | Type | +| ------ | ------ | +| `domNode` | `Node` | -##### Returns +### Returns `void` -___ -#### trackContentImpressionsWithinNode + -▸ **trackContentImpressionsWithinNode**(`domNode`): `void` -##### Parameters +*** -| Name | Type | -| :------ | :------ | -| `domNode` | `Node` | - -##### Returns - -`void` -___ +## trackContentInteraction() -#### trackContentInteraction - -▸ **trackContentInteraction**(`contentInteraction`, `contentName`, `contentPiece`, `contentTarget`): `void` +> **trackContentInteraction**(`contentInteraction`, `contentName`, `contentPiece`, `contentTarget`): `void` Tracks manual content interaction event -##### Parameters +### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | +| Parameter | Type | Description | +| ------ | ------ | ------ | | `contentInteraction` | `string` | Type of interaction (e.g. "click") | | `contentName` | `string` | Name of a content block | | `contentPiece` | `string` | Name of the content that was displayed (e.g. link to an image) | | `contentTarget` | `string` | Where the content leads to (e.g. URL of some external website) | -##### Returns +### Returns `void` -___ -#### trackContentInteractionNode + + + +*** + -▸ **trackContentInteractionNode**(`domNode`, `contentInteraction?`): `void` +## trackContentInteractionNode() + +> **trackContentInteractionNode**(`domNode`, `contentInteraction?`): `void` Tracks interaction with a block in domNode. Can be called from code placed in onclick attribute -##### Parameters +### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | +| Parameter | Type | Description | +| ------ | ------ | ------ | | `domNode` | `Node` | Node marked as content block or containing content blocks. If content block can’t be found, nothing will tracked. | | `contentInteraction?` | `string` | Name of interaction (e.g. "click") | -##### Returns +### Returns `void` -___ -#### trackVisibleContentImpressions + + + +*** + -▸ **trackVisibleContentImpressions**(`checkOnScroll?`, `watchInterval?`): `void` +## trackVisibleContentImpressions() + +> **trackVisibleContentImpressions**(`checkOnScroll?`, `watchInterval?`): `void` Scans DOM for all visible content blocks and tracks impressions -##### Parameters +### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | +| Parameter | Type | Description | +| ------ | ------ | ------ | | `checkOnScroll?` | `boolean` | Whether to scan for visible content on scroll event | | `watchInterval?` | `number` | Delay, in milliseconds, between scans for new visible content. Periodic checks can be disabled by passing 0 | -##### Returns +### Returns `void` - + + + +*** ## CookieManagement -### Table of contents +- [deleteCookies](#namespacescookiemanagementfunctionsdeletecookiesmd) +- [disableCookies](#namespacescookiemanagementfunctionsdisablecookiesmd) +- [enableCookies](#namespacescookiemanagementfunctionsenablecookiesmd) +- [getConfigVisitorCookieTimeout](#namespacescookiemanagementfunctionsgetconfigvisitorcookietimeoutmd) +- [getCookieDomain](#namespacescookiemanagementfunctionsgetcookiedomainmd) +- [getCookiePath](#namespacescookiemanagementfunctionsgetcookiepathmd) +- [getSessionCookieTimeout](#namespacescookiemanagementfunctionsgetsessioncookietimeoutmd) +- [hasCookies](#namespacescookiemanagementfunctionshascookiesmd) +- [setCookieDomain](#namespacescookiemanagementfunctionssetcookiedomainmd) +- [setCookieNamePrefix](#namespacescookiemanagementfunctionssetcookienameprefixmd) +- [setCookiePath](#namespacescookiemanagementfunctionssetcookiepathmd) +- [setReferralCookieTimeout](#namespacescookiemanagementfunctionssetreferralcookietimeoutmd) +- [setSecureCookie](#namespacescookiemanagementfunctionssetsecurecookiemd) +- [setSessionCookieTimeout](#namespacescookiemanagementfunctionssetsessioncookietimeoutmd) +- [setVisitorCookieTimeout](#namespacescookiemanagementfunctionssetvisitorcookietimeoutmd) +- [setVisitorIdCookie](#namespacescookiemanagementfunctionssetvisitoridcookiemd) -- [deleteCookies](#deletecookies) -- [disableCookies](#disablecookies) -- [enableCookies](#enablecookies) -- [getConfigVisitorCookieTimeout](#getconfigvisitorcookietimeout) -- [getCookieDomain](#getcookiedomain) -- [getCookiePath](#getcookiepath) -- [getSessionCookieTimeout](#getsessioncookietimeout) -- [hasCookies](#hascookies) -- [setCookieDomain](#setcookiedomain) -- [setCookieNamePrefix](#setcookienameprefix) -- [setCookiePath](#setcookiepath) -- [setReferralCookieTimeout](#setreferralcookietimeout) -- [setSecureCookie](#setsecurecookie) -- [setSessionCookieTimeout](#setsessioncookietimeout) -- [setVisitorCookieTimeout](#setvisitorcookietimeout) -- [setVisitorIdCookie](#setvisitoridcookie) + -#### deleteCookies -▸ **deleteCookies**(): `void` +*** + + +## deleteCookies() + +> **deleteCookies**(): `void` Deletes existing tracking cookies on the next page view -##### Returns +### Returns `void` -___ -#### disableCookies + + -▸ **disableCookies**(): `void` +*** + + +## disableCookies() + +> **disableCookies**(): `void` Disables all first party cookies. Existing cookies will be deleted in the next page view -##### Returns +### Returns `void` -___ -#### enableCookies + + -▸ **enableCookies**(): `void` +*** + + +## enableCookies() + +> **enableCookies**(): `void` Enables all first party cookies. Cookies will be created on the next tracking request -##### Returns +### Returns `void` -___ -#### getConfigVisitorCookieTimeout + + -▸ **getConfigVisitorCookieTimeout**(): `Promise`\<`number`\> +*** + + +## getConfigVisitorCookieTimeout() + +> **getConfigVisitorCookieTimeout**(): `Promise`\<`number`\> Returns expiration time of visitor cookies (in milliseconds) -##### Returns +### Returns `Promise`\<`number`\> -___ -#### getCookieDomain + + -▸ **getCookieDomain**(): `Promise`\<`string`\> +*** + + +## getCookieDomain() + +> **getCookieDomain**(): `Promise`\<`string`\> Returns domain of the analytics tracking cookies (set with setCookieDomain()). -##### Returns +### Returns `Promise`\<`string`\> -___ -#### getCookiePath + + -▸ **getCookiePath**(): `Promise`\<`string`\> +*** + + +## getCookiePath() + +> **getCookiePath**(): `Promise`\<`string`\> Returns the analytics tracking cookies path -##### Returns +### Returns `Promise`\<`string`\> -___ -#### getSessionCookieTimeout + + -▸ **getSessionCookieTimeout**(): `Promise`\<`number`\> +*** + + +## getSessionCookieTimeout() + +> **getSessionCookieTimeout**(): `Promise`\<`number`\> Returns expiration time of session cookies -##### Returns +### Returns `Promise`\<`number`\> -___ -#### hasCookies + + -▸ **hasCookies**(): `Promise`\<`boolean`\> +*** + + +## hasCookies() + +> **hasCookies**(): `Promise`\<`boolean`\> Returns true if cookies are enabled in this browser -##### Returns +### Returns `Promise`\<`boolean`\> -___ -#### setCookieDomain + + -▸ **setCookieDomain**(`domain`): `void` +*** + + +## setCookieDomain() + +> **setCookieDomain**(`domain`): `void` Sets the domain for the analytics tracking cookies -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `domain` | `string` | -##### Returns +### Returns `void` -___ -#### setCookieNamePrefix + + -▸ **setCookieNamePrefix**(`prefix`): `void` +*** + + +## setCookieNamePrefix() + +> **setCookieNamePrefix**(`prefix`): `void` Sets the prefix for analytics tracking cookies. Default is "_pk_". -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `prefix` | `string` | -##### Returns +### Returns `void` -___ -#### setCookiePath + + -▸ **setCookiePath**(`path`): `void` +*** + + +## setCookiePath() + +> **setCookiePath**(`path`): `void` Sets the analytics tracking cookies path -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `path` | `string` | -##### Returns +### Returns `void` -___ -#### setReferralCookieTimeout + + -▸ **setReferralCookieTimeout**(`seconds`): `void` +*** + + +## setReferralCookieTimeout() + +> **setReferralCookieTimeout**(`seconds`): `void` Sets the expiration time of referral cookies -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `seconds` | `number` | -##### Returns +### Returns `void` -___ -#### setSecureCookie + + -▸ **setSecureCookie**(`secure`): `void` +*** + + +## setSecureCookie() + +> **setSecureCookie**(`secure`): `void` Toggles the secure cookie flag on all first party cookies (if you are using HTTPS) -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `secure` | `boolean` | -##### Returns +### Returns `void` -___ -#### setSessionCookieTimeout + + -▸ **setSessionCookieTimeout**(`seconds`): `void` +*** + + +## setSessionCookieTimeout() + +> **setSessionCookieTimeout**(`seconds`): `void` Sets the expiration time of session cookies -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `seconds` | `number` | -##### Returns +### Returns `void` -___ -#### setVisitorCookieTimeout + + -▸ **setVisitorCookieTimeout**(`seconds`): `void` +*** + + +## setVisitorCookieTimeout() + +> **setVisitorCookieTimeout**(`seconds`): `void` Sets the expiration time of visitor cookies -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `seconds` | `number` | -##### Returns +### Returns `void` -___ -#### setVisitorIdCookie + -▸ **setVisitorIdCookie**(): `void` -Sets cookie containing [analytics ID](https://developers.piwik.pro/en/latest/glossary.html#term-analytics-id) in browser +*** -##### Returns -`void` +## setVisitorIdCookie() +> **setVisitorIdCookie**(): `void` - +Sets cookie containing [analytics ID](https://developers.piwik.pro/en/latest/glossary.html#term-analytics-id) in browser +### Returns -## CrossDomainTracking +`void` -### Table of contents -#### Type Aliases + + -- [LinkDecorator](#linkdecorator) -- [VisitorIdGetter](#visitoridgetter) +*** -- [customCrossDomainLinkDecorator](#customcrossdomainlinkdecorator) -- [customCrossDomainLinkVisitorIdGetter](#customcrossdomainlinkvisitoridgetter) -- [disableCrossDomainLinking](#disablecrossdomainlinking) -- [enableCrossDomainLinking](#enablecrossdomainlinking) -- [getCrossDomainLinkingUrlParameter](#getcrossdomainlinkingurlparameter) -- [isCrossDomainLinkingEnabled](#iscrossdomainlinkingenabled) -- [setCrossDomainLinkingTimeout](#setcrossdomainlinkingtimeout) +## CrossDomainTracking ### Type Aliases -#### LinkDecorator +- [LinkDecorator](#namespacescrossdomaintrackingtype-aliaseslinkdecoratormd) +- [VisitorIdGetter](#namespacescrossdomaintrackingtype-aliasesvisitoridgettermd) -Ƭ **LinkDecorator**: (`url`: `string`, `value`: `string`, `name`: `string`) => `string` \| ``null`` -##### Type declaration +- [customCrossDomainLinkDecorator](#namespacescrossdomaintrackingfunctionscustomcrossdomainlinkdecoratormd) +- [customCrossDomainLinkVisitorIdGetter](#namespacescrossdomaintrackingfunctionscustomcrossdomainlinkvisitoridgettermd) +- [disableCrossDomainLinking](#namespacescrossdomaintrackingfunctionsdisablecrossdomainlinkingmd) +- [enableCrossDomainLinking](#namespacescrossdomaintrackingfunctionsenablecrossdomainlinkingmd) +- [getCrossDomainLinkingUrlParameter](#namespacescrossdomaintrackingfunctionsgetcrossdomainlinkingurlparametermd) +- [isCrossDomainLinkingEnabled](#namespacescrossdomaintrackingfunctionsiscrossdomainlinkingenabledmd) +- [setCrossDomainLinkingTimeout](#namespacescrossdomaintrackingfunctionssetcrossdomainlinkingtimeoutmd) -▸ (`url`, `value`, `name`): `string` \| ``null`` -###### Parameters + -| Name | Type | -| :------ | :------ | -| `url` | `string` | -| `value` | `string` | -| `name` | `string` | -###### Returns +*** -`string` \| ``null`` -___ +## customCrossDomainLinkDecorator() -#### VisitorIdGetter +> **customCrossDomainLinkDecorator**(`decorator`): `void` -Ƭ **VisitorIdGetter**: (`url`: `string`, `name`: `string`) => `string` +Sets custom cross domains URL decorator for injecting visitor ID into URLs. Used when cross domain linking is enabled. -##### Type declaration +### Parameters -▸ (`url`, `name`): `string` +| Parameter | Type | +| ------ | ------ | +| `decorator` | [`LinkDecorator`](#namespacescrossdomaintrackingtype-aliaseslinkdecoratormd) | -###### Parameters +### Returns -| Name | Type | -| :------ | :------ | -| `url` | `string` | -| `name` | `string` | +`void` -###### Returns -`string` + -#### customCrossDomainLinkDecorator +*** -▸ **customCrossDomainLinkDecorator**(`decorator`): `void` -Sets custom cross domains URL decorator for injecting visitor ID into URLs. Used when cross domain linking is enabled. +## customCrossDomainLinkVisitorIdGetter() -##### Parameters +> **customCrossDomainLinkVisitorIdGetter**(`getter`): `void` -| Name | Type | -| :------ | :------ | -| `decorator` | [`LinkDecorator`](#linkdecorator) | +Sets custom cross domain URL parser for extracting visitor ID from URLs. Should extract data injected by URL decorator. The getter should return visitor ID extracted from page URL. + +### Parameters -##### Returns +| Parameter | Type | +| ------ | ------ | +| `getter` | [`VisitorIdGetter`](#namespacescrossdomaintrackingtype-aliasesvisitoridgettermd) | + +### Returns `void` -___ -#### customCrossDomainLinkVisitorIdGetter + -▸ **customCrossDomainLinkVisitorIdGetter**(`getter`): `void` -Sets custom cross domain URL parser for extracting visitor ID from URLs. Should extract data injected by URL decorator. The getter should return visitor ID extracted from page URL. +*** -##### Parameters -| Name | Type | -| :------ | :------ | -| `getter` | [`VisitorIdGetter`](#visitoridgetter) | +## disableCrossDomainLinking() -##### Returns +> **disableCrossDomainLinking**(): `void` -`void` +Disables cross domain linking. -___ +### Returns -#### disableCrossDomainLinking +`void` -▸ **disableCrossDomainLinking**(): `void` -Disables cross domain linking. + -##### Returns -`void` +*** -___ -#### enableCrossDomainLinking +## enableCrossDomainLinking() -▸ **enableCrossDomainLinking**(): `void` +> **enableCrossDomainLinking**(): `void` Enables cross domain linking. Visitors across domains configured with "setDomains" function will be linked by passing visitor ID parameter in links. -##### Returns +### Returns `void` -___ -#### getCrossDomainLinkingUrlParameter + + + +*** + -▸ **getCrossDomainLinkingUrlParameter**(): `Promise`\<`string`\> +## getCrossDomainLinkingUrlParameter() + +> **getCrossDomainLinkingUrlParameter**(): `Promise`\<`string`\> Returns the name of a cross domain URL parameter (query parameter by default) holding visitor ID. This is "pk_vid" by default. -##### Returns +### Returns `Promise`\<`string`\> -___ -#### isCrossDomainLinkingEnabled + + + +*** + -▸ **isCrossDomainLinkingEnabled**(): `Promise`\<`boolean`\> +## isCrossDomainLinkingEnabled() + +> **isCrossDomainLinkingEnabled**(): `Promise`\<`boolean`\> Returns boolean telling whether cross domain linking is enabled. -##### Returns +### Returns `Promise`\<`boolean`\> -___ -#### setCrossDomainLinkingTimeout + + + +*** + -▸ **setCrossDomainLinkingTimeout**(`timeout`): `void` +## setCrossDomainLinkingTimeout() + +> **setCrossDomainLinkingTimeout**(`timeout`): `void` Changes the time in which two visits across domains will be linked. The default timeout is 180 seconds (3 minutes). -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `timeout` | `number` | -##### Returns +### Returns `void` - + + + +*** + + +## LinkDecorator + +> **LinkDecorator** = (`url`, `value`, `name`) => `string` \| `null` + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `url` | `string` | +| `value` | `string` | +| `name` | `string` | + +### Returns + +`string` \| `null` + + + + + +*** + + +## VisitorIdGetter + +> **VisitorIdGetter** = (`url`, `name`) => `string` + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `url` | `string` | +| `name` | `string` | + +### Returns + +`string` + + + + + +*** ## CustomDimensions -### Table of contents +- [deleteCustomDimension](#namespacescustomdimensionsfunctionsdeletecustomdimensionmd) +- [getCustomDimensionValue](#namespacescustomdimensionsfunctionsgetcustomdimensionvaluemd) +- [setCustomDimensionValue](#namespacescustomdimensionsfunctionssetcustomdimensionvaluemd) -- [deleteCustomDimension](#deletecustomdimension) -- [getCustomDimensionValue](#getcustomdimensionvalue) -- [setCustomDimensionValue](#setcustomdimensionvalue) + -#### deleteCustomDimension -▸ **deleteCustomDimension**(`customDimensionId`): `void` +*** + + +## deleteCustomDimension() + +> **deleteCustomDimension**(`customDimensionId`): `void` Removes a custom dimension with the specified ID. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `customDimensionId` | `string` \| `number` | -##### Returns +### Returns `void` -___ -#### getCustomDimensionValue + + -▸ **getCustomDimensionValue**(`customDimensionId`): `Promise`\<`string` \| `undefined`\> +*** + + +## getCustomDimensionValue() + +> **getCustomDimensionValue**(`customDimensionId`): `Promise`\<`string` \| `undefined`\> Returns the value of a custom dimension with the specified ID. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `customDimensionId` | `string` \| `number` | -##### Returns +### Returns `Promise`\<`string` \| `undefined`\> -___ -#### setCustomDimensionValue + + -▸ **setCustomDimensionValue**(`customDimensionId`, `customDimensionValue`): `void` +*** + + +## setCustomDimensionValue() + +> **setCustomDimensionValue**(`customDimensionId`, `customDimensionValue`): `void` Sets a custom dimension value to be used later. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `customDimensionId` | `string` \| `number` | | `customDimensionValue` | `string` | -##### Returns +### Returns `void` - + + + +*** ## CustomEvent -### Table of contents +- [trackEvent](#namespacescustomeventfunctionstrackeventmd) + + + -- [trackEvent](#trackevent) +*** -#### trackEvent -▸ **trackEvent**(`category`, `action`, `name?`, `value?`, `dimensions?`): `void` +## trackEvent() + +> **trackEvent**(`category`, `action`, `name?`, `value?`, `dimensions?`): `void` Tracks a custom event, e.g. when a visitor interacts with the page -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `category` | `string` | | `action` | `string` | | `name?` | `string` | | `value?` | `number` | -| `dimensions?` | [`Dimensions`](#dimensions) | +| `dimensions?` | [`Dimensions`](#type-aliasesdimensionsmd) | -##### Returns +### Returns `void` - + + + +*** ## DataLayer -### Table of contents +### Type Aliases -#### Type Aliases +- [DataLayerEntry](#namespacesdatalayertype-aliasesdatalayerentrymd) -- [DataLayerEntry](#datalayerentry) +- [push](#namespacesdatalayerfunctionspushmd) +- [setDataLayerName](#namespacesdatalayerfunctionssetdatalayernamemd) -- [push](#push) -- [setDataLayerName](#setdatalayername) -### Type Aliases + -#### DataLayerEntry -Ƭ **DataLayerEntry**: `Record`\<`string`, `AnyData`\> +*** -#### push +## push() -▸ **push**(`data`): `number` +> **push**(`data`): `number` Adds entry to a data layer -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `data` | [`DataLayerEntry`](#datalayerentry) | +| Parameter | Type | +| ------ | ------ | +| `data` | [`DataLayerEntry`](#namespacesdatalayertype-aliasesdatalayerentrymd) | -##### Returns +### Returns `number` -___ -#### setDataLayerName + + + +*** -▸ **setDataLayerName**(`name`): `void` -##### Parameters +## setDataLayerName() -| Name | Type | -| :------ | :------ | +> **setDataLayerName**(`name`): `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `name` | `string` | -##### Returns +### Returns `void` - + + + +*** + + +## DataLayerEntry + +> **DataLayerEntry** = `Record`\<`string`, `AnyData`\> + + + + + +*** ## DownloadAndOutlink -### Table of contents +- [addDownloadClasses](#namespacesdownloadandoutlinkfunctionsadddownloadclassesmd) +- [addDownloadExtensions](#namespacesdownloadandoutlinkfunctionsadddownloadextensionsmd) +- [enableLinkTracking](#namespacesdownloadandoutlinkfunctionsenablelinktrackingmd) +- [getDownloadClasses](#namespacesdownloadandoutlinkfunctionsgetdownloadclassesmd) +- [getLinkTrackingTimer](#namespacesdownloadandoutlinkfunctionsgetlinktrackingtimermd) +- [removeDownloadClasses](#namespacesdownloadandoutlinkfunctionsremovedownloadclassesmd) +- [removeDownloadExtensions](#namespacesdownloadandoutlinkfunctionsremovedownloadextensionsmd) +- [setDownloadClasses](#namespacesdownloadandoutlinkfunctionssetdownloadclassesmd) +- [setDownloadExtensions](#namespacesdownloadandoutlinkfunctionssetdownloadextensionsmd) +- [setIgnoreClasses](#namespacesdownloadandoutlinkfunctionssetignoreclassesmd) +- [setLinkClasses](#namespacesdownloadandoutlinkfunctionssetlinkclassesmd) +- [setLinkTrackingTimer](#namespacesdownloadandoutlinkfunctionssetlinktrackingtimermd) +- [trackLink](#namespacesdownloadandoutlinkfunctionstracklinkmd) -- [addDownloadClasses](#adddownloadclasses) -- [addDownloadExtensions](#adddownloadextensions) -- [enableLinkTracking](#enablelinktracking) -- [getDownloadClasses](#getdownloadclasses) -- [getLinkTrackingTimer](#getlinktrackingtimer) -- [removeDownloadClasses](#removedownloadclasses) -- [removeDownloadExtensions](#removedownloadextensions) -- [setDownloadClasses](#setdownloadclasses) -- [setDownloadExtensions](#setdownloadextensions) -- [setIgnoreClasses](#setignoreclasses) -- [setLinkClasses](#setlinkclasses) -- [setLinkTrackingTimer](#setlinktrackingtimer) -- [trackLink](#tracklink) + -#### addDownloadClasses -▸ **addDownloadClasses**(`classes`): `void` +*** + + +## addDownloadClasses() + +> **addDownloadClasses**(`classes`): `void` Adds new classes to the download classes list -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `classes` | `string`[] | -##### Returns +### Returns `void` -___ -#### addDownloadExtensions + + -▸ **addDownloadExtensions**(`extensions`): `void` +*** + + +## addDownloadExtensions() + +> **addDownloadExtensions**(`extensions`): `void` Adds new extensions to the download extensions list -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `extensions` | `string`[] | -##### Returns +### Returns `void` -___ -#### enableLinkTracking + + -▸ **enableLinkTracking**(`trackAlsoMiddleAndRightClicks?`): `void` +*** + + +## enableLinkTracking() + +> **enableLinkTracking**(`trackAlsoMiddleAndRightClicks?`): `void` Enables automatic link tracking. If called with `true`, 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 -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `trackAlsoMiddleAndRightClicks?` | `boolean` | -##### Returns +### Returns `void` -___ -#### getDownloadClasses + + -▸ **getDownloadClasses**(): `Promise`\<`string`[]\> +*** + + +## getDownloadClasses() + +> **getDownloadClasses**(): `Promise`\<`string`[]\> Returns list of download classes (CSS classes that indicate a link is a download) -##### Returns +### Returns `Promise`\<`string`[]\> -___ -#### getLinkTrackingTimer + + -▸ **getLinkTrackingTimer**(): `Promise`\<`number`\> +*** + + +## getLinkTrackingTimer() + +> **getLinkTrackingTimer**(): `Promise`\<`number`\> Returns lock/wait time after a request set by setLinkTrackingTimer -##### Returns +### Returns `Promise`\<`number`\> -___ -#### removeDownloadClasses + -▸ **removeDownloadClasses**(`classes`): `void` -Removes classes from the download classes list +*** -##### Parameters -| Name | Type | -| :------ | :------ | +## removeDownloadClasses() + +> **removeDownloadClasses**(`classes`): `void` + +Removes classes from the download classes list + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `classes` | `string`[] | -##### Returns +### Returns `void` -___ -#### removeDownloadExtensions + -▸ **removeDownloadExtensions**(`extensions`): `void` + +*** + + +## removeDownloadExtensions() + +> **removeDownloadExtensions**(`extensions`): `void` Removes extensions from the download extensions list -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `extensions` | `string`[] | -##### Returns +### Returns `void` -___ -#### setDownloadClasses + + -▸ **setDownloadClasses**(`classes`): `void` +*** + + +## setDownloadClasses() + +> **setDownloadClasses**(`classes`): `void` Sets a list of class names that indicate whether a list is a download and not an outlink -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `classes` | `string`[] | -##### Returns +### Returns `void` -___ -#### setDownloadExtensions + + + +*** -▸ **setDownloadExtensions**(`extensions`): `void` + +## setDownloadExtensions() + +> **setDownloadExtensions**(`extensions`): `void` Overwrites the list of file extensions indicating that a link is a download -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `extensions` | `string`[] | -##### Returns +### Returns `void` -___ -#### setIgnoreClasses + + + +*** -▸ **setIgnoreClasses**(`classes`): `void` + +## setIgnoreClasses() + +> **setIgnoreClasses**(`classes`): `void` Set a list of class names that indicate a link should not be tracked -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `classes` | `string`[] | -##### Returns +### Returns `void` -___ -#### setLinkClasses + + + +*** + -▸ **setLinkClasses**(`classes`): `void` +## setLinkClasses() + +> **setLinkClasses**(`classes`): `void` Sets a list of class names that indicate whether a link is an outlink and not download -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `classes` | `string`[] | -##### Returns +### Returns `void` -___ -#### setLinkTrackingTimer + + + +*** + -▸ **setLinkTrackingTimer**(`time`): `void` +## setLinkTrackingTimer() + +> **setLinkTrackingTimer**(`time`): `void` 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 @@ -1260,597 +1405,753 @@ 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 -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `time` | `number` | -##### Returns +### Returns `void` -___ -#### trackLink + + + +*** + + +## trackLink() -▸ **trackLink**(`url`, `linkType`, `dimensions?`, `callback?`): `void` +> **trackLink**(`url`, `linkType`, `dimensions?`, `callback?`): `void` Manually tracks outlink or download event with provided values -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `url` | `string` | | `linkType` | `string` | -| `dimensions?` | [`Dimensions`](#dimensions) | +| `dimensions?` | [`Dimensions`](#type-aliasesdimensionsmd) | | `callback?` | () => `void` | -##### Returns +### Returns `void` - + + + +*** ## ErrorTracking -### Table of contents + +- [enableJSErrorTracking](#namespaceserrortrackingfunctionsenablejserrortrackingmd) +- [trackError](#namespaceserrortrackingfunctionstrackerrormd) -- [enableJSErrorTracking](#enablejserrortracking) -- [trackError](#trackerror) + -#### enableJSErrorTracking +*** -▸ **enableJSErrorTracking**(`unique?`): `void` + +## enableJSErrorTracking() + +> **enableJSErrorTracking**(`unique?`): `void` Enables tracking of unhandled JavaScript errors. -##### Parameters +### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | +| Parameter | Type | Description | +| ------ | ------ | ------ | | `unique?` | `boolean` | track only unique errors | -##### Returns +### Returns `void` -___ -#### trackError + + + +*** + -▸ **trackError**(`error`): `void` +## trackError() + +> **trackError**(`error`): `void` Attempts to send error tracking request using same format as native errors caught by enableJSErrorTracking(). Such error request will still follow rules set for tracker, so it will be sent only when JS error tracking is enabled -([enableJSErrorTracking](#enablejserrortracking) function was called before this attempt). It will also respect rules for tracking only unique errors. +([enableJSErrorTracking](#namespaceserrortrackingfunctionsenablejserrortrackingmd) function was called before this attempt). It will also respect rules for tracking only unique errors. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `error` | `Error` | -##### Returns +### Returns `void` - + + + +*** ## GoalConversions -### Table of contents +- [trackGoal](#namespacesgoalconversionsfunctionstrackgoalmd) -- [trackGoal](#trackgoal) + -#### trackGoal -▸ **trackGoal**(`goalId`, `conversionValue`, `dimensions?`, `options?`): `void` +*** + + +## trackGoal() + +> **trackGoal**(`goalId`, `conversionValue`, `dimensions?`, `options?`): `void` Tracks manual goal conversion -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `goalId` | `string` \| `number` | | `conversionValue` | `number` | -| `dimensions?` | [`Dimensions`](#dimensions) | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| `dimensions?` | [`Dimensions`](#type-aliasesdimensionsmd) | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` - + + + +*** ## Heartbeat -### Table of contents + +- [disableHeartBeatTimer](#namespacesheartbeatfunctionsdisableheartbeattimermd) +- [enableHeartBeatTimer](#namespacesheartbeatfunctionsenableheartbeattimermd) + + + -- [disableHeartBeatTimer](#disableheartbeattimer) -- [enableHeartBeatTimer](#enableheartbeattimer) +*** -#### disableHeartBeatTimer +## disableHeartBeatTimer() -▸ **disableHeartBeatTimer**(): `void` +> **disableHeartBeatTimer**(): `void` Disables sending heartbeats if they were previously enabled by "enableHeartBeatTimer" function. -##### Returns +### Returns `void` -___ -#### enableHeartBeatTimer + -▸ **enableHeartBeatTimer**(`delays?`): `void` + +*** + + +## enableHeartBeatTimer() + +> **enableHeartBeatTimer**(`delays?`): `void` When a visitor is not producing any events (e.g. because they are reading an article or watching a video), we don’t know if they are still on the page. This might skew page statistics, e.g. time on page value. Heartbeat timer allows us to determine how much time visitors spend on a page by sending heartbeats to the Tracker as long as the page is in focus. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `delays?` | `number`[] | -##### Returns +### Returns `void` - + + + +*** ## Miscellaneous -### Table of contents +- [setTrackingSourceProvider](#namespacesmiscellaneousfunctionssettrackingsourceprovidermd) + + + -- [setTrackingSourceProvider](#settrackingsourceprovider) +*** -#### setTrackingSourceProvider -▸ **setTrackingSourceProvider**(`provider`, `version`): `void` +## setTrackingSourceProvider() + +> **setTrackingSourceProvider**(`provider`, `version`): `void` Adds metadata about used framework -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `provider` | `string` | | `version` | `string` | -##### Returns +### Returns `void` - + + + +*** ## PageViews -### Table of contents + +- [trackPageView](#namespacespageviewsfunctionstrackpageviewmd) -- [trackPageView](#trackpageview) + -#### trackPageView +*** -▸ **trackPageView**(`customPageTitle?`): `void` + +## trackPageView() + +> **trackPageView**(`customPageTitle?`): `void` Tracks a visit on the page that the function was run on -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `customPageTitle?` | `string` | -##### Returns +### Returns `void` - + + + +*** ## SiteSearch -### Table of contents +- [trackSiteSearch](#namespacessitesearchfunctionstracksitesearchmd) + + + -- [trackSiteSearch](#tracksitesearch) +*** -#### trackSiteSearch -▸ **trackSiteSearch**(`keyword`, `category?`, `searchCount?`, `dimensions?`): `void` +## trackSiteSearch() + +> **trackSiteSearch**(`keyword`, `category?`, `searchCount?`, `dimensions?`): `void` Tracks search requests on a website -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `keyword` | `string` | | `category?` | `string` | | `searchCount?` | `number` | -| `dimensions?` | [`Dimensions`](#dimensions) | +| `dimensions?` | [`Dimensions`](#type-aliasesdimensionsmd) | -##### Returns +### Returns `void` - + + + +*** ## UserManagement -### Table of contents + +- [deanonymizeUser](#namespacesusermanagementfunctionsdeanonymizeusermd) +- [getUserId](#namespacesusermanagementfunctionsgetuseridmd) +- [getVisitorId](#namespacesusermanagementfunctionsgetvisitoridmd) +- [getVisitorInfo](#namespacesusermanagementfunctionsgetvisitorinfomd) +- [resetUserId](#namespacesusermanagementfunctionsresetuseridmd) +- [setUserId](#namespacesusermanagementfunctionssetuseridmd) +- [setUserIsAnonymous](#namespacesusermanagementfunctionssetuserisanonymousmd) + + + -- [deanonymizeUser](#deanonymizeuser) -- [getUserId](#getuserid) -- [getVisitorId](#getvisitorid) -- [getVisitorInfo](#getvisitorinfo) -- [resetUserId](#resetuserid) -- [setUserId](#setuserid) -- [setUserIsAnonymous](#setuserisanonymous) +*** -#### deanonymizeUser +## deanonymizeUser() -▸ **deanonymizeUser**(): `void` +> **deanonymizeUser**(): `void` Disables anonymous tracking and sends deanonymization event to the Tracker. Recommended method for disabling anonymous tracking. -##### Returns +### Returns `void` -___ -#### getUserId + -▸ **getUserId**(): `Promise`\<`string`\> + +*** + + +## getUserId() + +> **getUserId**(): `Promise`\<`string`\> The function that will return user ID -##### Returns +### Returns `Promise`\<`string`\> -___ -#### getVisitorId + + -▸ **getVisitorId**(): `Promise`\<`string`\> +*** + + +## getVisitorId() + +> **getVisitorId**(): `Promise`\<`string`\> Returns 16-character hex ID of the visitor -##### Returns +### Returns `Promise`\<`string`\> -___ -#### getVisitorInfo + + -▸ **getVisitorInfo**(): `Promise`\<[`VisitorInfo`](#visitorinfo)\> +*** + + +## getVisitorInfo() + +> **getVisitorInfo**(): `Promise`\<[`VisitorInfo`](#type-aliasesvisitorinfomd)\> Returns visitor information in an array -##### Returns +### Returns + +`Promise`\<[`VisitorInfo`](#type-aliasesvisitorinfomd)\> + -`Promise`\<[`VisitorInfo`](#visitorinfo)\> + -___ -#### resetUserId +*** -▸ **resetUserId**(): `void` + +## resetUserId() + +> **resetUserId**(): `void` Clears previously set userID, e.g. when visitor logs out -##### Returns +### Returns `void` -___ -#### setUserId + + + +*** -▸ **setUserId**(`userId`): `void` + +## setUserId() + +> **setUserId**(`userId`): `void` 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 -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `userId` | `string` | -##### Returns +### Returns `void` -___ -#### setUserIsAnonymous + + + +*** + -▸ **setUserIsAnonymous**(`isAnonymous`): `void` +## setUserIsAnonymous() + +> **setUserIsAnonymous**(`isAnonymous`): `void` Enables or disables anonymous tracking (anonymous = without consent). The next emitted event will have anonymous mode set accordingly. -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | +| Parameter | Type | +| ------ | ------ | | `isAnonymous` | `boolean` | -##### Returns +### Returns `void` - + + + +*** ## eCommerce -### Table of contents +- [~~addEcommerceItem~~](#namespacesecommercefunctionsaddecommerceitemmd) +- [~~clearEcommerceCart~~](#namespacesecommercefunctionsclearecommercecartmd) +- [ecommerceAddToCart](#namespacesecommercefunctionsecommerceaddtocartmd) +- [ecommerceCartUpdate](#namespacesecommercefunctionsecommercecartupdatemd) +- [ecommerceOrder](#namespacesecommercefunctionsecommerceordermd) +- [ecommerceProductDetailView](#namespacesecommercefunctionsecommerceproductdetailviewmd) +- [ecommerceRemoveFromCart](#namespacesecommercefunctionsecommerceremovefromcartmd) +- [~~getEcommerceItems~~](#namespacesecommercefunctionsgetecommerceitemsmd) +- [~~removeEcommerceItem~~](#namespacesecommercefunctionsremoveecommerceitemmd) +- [~~setEcommerceView~~](#namespacesecommercefunctionssetecommerceviewmd) +- [~~trackEcommerceCartUpdate~~](#namespacesecommercefunctionstrackecommercecartupdatemd) +- [~~trackEcommerceOrder~~](#namespacesecommercefunctionstrackecommerceordermd) -- [addEcommerceItem](#addecommerceitem) -- [clearEcommerceCart](#clearecommercecart) -- [ecommerceAddToCart](#ecommerceaddtocart) -- [ecommerceCartUpdate](#ecommercecartupdate) -- [ecommerceOrder](#ecommerceorder) -- [ecommerceProductDetailView](#ecommerceproductdetailview) -- [ecommerceRemoveFromCart](#ecommerceremovefromcart) -- [getEcommerceItems](#getecommerceitems) -- [removeEcommerceItem](#removeecommerceitem) -- [setEcommerceView](#setecommerceview) -- [trackEcommerceCartUpdate](#trackecommercecartupdate) -- [trackEcommerceOrder](#trackecommerceorder) + -#### addEcommerceItem -▸ **addEcommerceItem**(`productSKU`, `productName`, `productCategory`, `productPrice`, `productQuantity`): `void` +*** -##### Parameters -| Name | Type | -| :------ | :------ | +## ~~addEcommerceItem()~~ + +> **addEcommerceItem**(`productSKU`, `productName`, `productCategory`, `productPrice`, `productQuantity`): `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `productSKU` | `string` | | `productName` | `string` | | `productCategory` | `string` \| `string`[] | | `productPrice` | `number` | | `productQuantity` | `number` | -##### Returns +### Returns `void` -**`Deprecated`** +### Deprecated Please use the ecommerceAddToCart instead. -___ -#### clearEcommerceCart + + + +*** -▸ **clearEcommerceCart**(): `void` -##### Returns +## ~~clearEcommerceCart()~~ + +> **clearEcommerceCart**(): `void` + +### Returns `void` -**`Deprecated`** +### Deprecated + + + -___ -#### ecommerceAddToCart +*** -▸ **ecommerceAddToCart**(`products`, `options?`): `void` + +## ecommerceAddToCart() + +> **ecommerceAddToCart**(`products`, `options?`): `void` Tracks action of adding products to a cart -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `products` | [`Product`](#product)[] | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| Parameter | Type | +| ------ | ------ | +| `products` | [`Product`](#type-aliasesproductmd)[] | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` -___ -#### ecommerceCartUpdate + + + +*** + -▸ **ecommerceCartUpdate**(`products`, `grandTotal`, `options?`): `void` +## ecommerceCartUpdate() + +> **ecommerceCartUpdate**(`products`, `grandTotal`, `options?`): `void` Tracks current state of a cart -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `products` | [`Product`](#product)[] | +| Parameter | Type | +| ------ | ------ | +| `products` | [`Product`](#type-aliasesproductmd)[] | | `grandTotal` | `string` \| `number` | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` -___ -#### ecommerceOrder + + + +*** + -▸ **ecommerceOrder**(`products`, `paymentInformation`, `options?`): `void` +## ecommerceOrder() + +> **ecommerceOrder**(`products`, `paymentInformation`, `options?`): `void` Tracks conversion, including products and payment details -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `products` | [`Product`](#product)[] | -| `paymentInformation` | [`PaymentInformation`](#paymentinformation) | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| Parameter | Type | +| ------ | ------ | +| `products` | [`Product`](#type-aliasesproductmd)[] | +| `paymentInformation` | [`PaymentInformation`](#type-aliasespaymentinformationmd) | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` -___ -#### ecommerceProductDetailView + + + +*** + + +## ecommerceProductDetailView() -▸ **ecommerceProductDetailView**(`products`, `options?`): `void` +> **ecommerceProductDetailView**(`products`, `options?`): `void` Tracks action of viewing product page -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `products` | [`Product`](#product)[] | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| Parameter | Type | +| ------ | ------ | +| `products` | [`Product`](#type-aliasesproductmd)[] | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` -___ -#### ecommerceRemoveFromCart + + + +*** + + +## ecommerceRemoveFromCart() -▸ **ecommerceRemoveFromCart**(`products`, `options?`): `void` +> **ecommerceRemoveFromCart**(`products`, `options?`): `void` Tracks action of removing a products from a cart -##### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `products` | [`Product`](#product)[] | -| `options?` | [`EcommerceOptions`](#ecommerceoptions) | +| Parameter | Type | +| ------ | ------ | +| `products` | [`Product`](#type-aliasesproductmd)[] | +| `options?` | [`EcommerceOptions`](#type-aliasesecommerceoptionsmd) | -##### Returns +### Returns `void` -___ -#### getEcommerceItems + -▸ **getEcommerceItems**(): `Promise`\<`object`\> -##### Returns +*** + + +## ~~getEcommerceItems()~~ + +> **getEcommerceItems**(): `Promise`\<`object`\> + +### Returns `Promise`\<`object`\> -**`Deprecated`** +### Deprecated + -___ + -#### removeEcommerceItem -▸ **removeEcommerceItem**(`productSKU`): `void` +*** -##### Parameters -| Name | Type | -| :------ | :------ | +## ~~removeEcommerceItem()~~ + +> **removeEcommerceItem**(`productSKU`): `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `productSKU` | `string` | -##### Returns +### Returns `void` -**`Deprecated`** +### Deprecated Please use the ecommerceRemoveFromCart instead. -___ -#### setEcommerceView + + -▸ **setEcommerceView**(`productSKU`, `productName?`, `productCategory?`, `productPrice?`): `void` +*** -##### Parameters -| Name | Type | -| :------ | :------ | +## ~~setEcommerceView()~~ + +> **setEcommerceView**(`productSKU`, `productName?`, `productCategory?`, `productPrice?`): `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `productSKU` | `string` | | `productName?` | `string` | | `productCategory?` | `string`[] | | `productPrice?` | `string` | -##### Returns +### Returns `void` -**`Deprecated`** +### Deprecated + + + -___ -#### trackEcommerceCartUpdate +*** -▸ **trackEcommerceCartUpdate**(`cartAmount`): `void` -##### Parameters +## ~~trackEcommerceCartUpdate()~~ -| Name | Type | -| :------ | :------ | +> **trackEcommerceCartUpdate**(`cartAmount`): `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | | `cartAmount` | `number` | -##### Returns +### Returns `void` -**`Deprecated`** +### Deprecated Please use the ecommerceCartUpdate instead. -___ -#### trackEcommerceOrder + + + +*** + -▸ **trackEcommerceOrder**(`orderId`, `orderGrandTotal`, `orderSubTotal?`, `orderTax?`, `orderShipping?`, `orderDiscount?`): `void` +## ~~trackEcommerceOrder()~~ -##### Parameters +> **trackEcommerceOrder**(`orderId`, `orderGrandTotal`, `orderSubTotal?`, `orderTax?`, `orderShipping?`, `orderDiscount?`): `void` -| Name | Type | -| :------ | :------ | +### Parameters + +| Parameter | Type | +| ------ | ------ | | `orderId` | `string` | | `orderGrandTotal` | `number` | | `orderSubTotal?` | `number` | @@ -1858,10 +2159,234 @@ ___ | `orderShipping?` | `number` | | `orderDiscount?` | `number` | -##### Returns +### Returns `void` -**`Deprecated`** +### Deprecated Please use the ecommerceOrder instead. + + + + + +*** + + +## Dimensions + +> **Dimensions** = `Record`\<`` `dimension${number}` ``, `string`\> + + + + + +*** + + +## EcommerceOptions + +> **EcommerceOptions** = `object` + +### Properties + +#### currencyCode? + +> `optional` **currencyCode?**: `string` + +Currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format. If not provided, the currency set in app settings will be used instead. + + + + + +*** + + +## GetInitScript + +> **GetInitScript** = (`params`) => `string` + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `params` | `GetInitScriptParams` | + +### Returns + +`string` + + + + + +*** + + +## InitOptions + +> **InitOptions** = `object` + +### Properties + +#### dataLayerName? + +> `optional` **dataLayerName?**: `string` + +Defaults to 'dataLayer' + + +#### nonce? + +> `optional` **nonce?**: `string` + + + + + +*** + + +## Initialize + +> **Initialize** = (`containerId`, `containerUrl`, `nonceOrOptions?`) => `void` + +### Parameters + +| Parameter | Type | +| ------ | ------ | +| `containerId` | `string` | +| `containerUrl` | `string` | +| `nonceOrOptions?` | `string` \| [`InitOptions`](#type-aliasesinitoptionsmd) | + +### Returns + +`void` + + + + + +*** + + +## PaymentInformation + +> **PaymentInformation** = `object` + +### Properties + +#### discount? + +> `optional` **discount?**: `number` \| `string` + + +#### grandTotal + +> **grandTotal**: `number` \| `string` + + +#### orderId + +> **orderId**: `string` + + +#### shipping? + +> `optional` **shipping?**: `number` \| `string` + + +#### subTotal? + +> `optional` **subTotal?**: `number` \| `string` + + +#### tax? + +> `optional` **tax?**: `number` \| `string` + + + + + +*** + + +## Product + +> **Product** = `object` + +### Properties + +#### brand? + +> `optional` **brand?**: `string` + + +#### category? + +> `optional` **category?**: `LimitedArrayFiveStrings` + + +#### customDimensions? + +> `optional` **customDimensions?**: `Record`\<`number`, `string`\> + + +#### name? + +> `optional` **name?**: `string` + + +#### price? + +> `optional` **price?**: `number` + + +#### quantity? + +> `optional` **quantity?**: `number` + + +#### sku + +> **sku**: `string` + + +#### variant? + +> `optional` **variant?**: `string` + + + + + +*** + + +## VisitorInfo + +> **VisitorInfo** = \[`"0"` \| `"1"`, `string`, `number`, `string` \| `number`, `number`, `number` \| `""`, `number` \| `""`\] + + + + + +*** + + +## default + +> **default**: `object` + +### Type Declaration + +#### getInitScript + +> **getInitScript**: [`GetInitScript`](#type-aliasesgetinitscriptmd) = `PiwikPro.getInitScript` + +#### initialize + +> **initialize**: [`Initialize`](#type-aliasesinitializemd) diff --git a/package.json b/package.json index 259abcc..8cba6e1 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,8 @@ "prettier": "^3.1.1", "react": "^18.2.0", "tslib": "^2.6.3", - "typedoc": "^0.25.13", - "typedoc-plugin-markdown": "^3.17.1", + "typedoc": "^0.28.19", + "typedoc-plugin-markdown": "^4.12.0", "typescript": "~5.4.5", "vite": "^6.4.3" }, diff --git a/scripts/postProcessDocs.js b/scripts/postProcessDocs.js index 34e3c02..c0689d2 100644 --- a/scripts/postProcessDocs.js +++ b/scripts/postProcessDocs.js @@ -6,21 +6,31 @@ const file = readFileSync(README, 'utf-8') const formattedOutput = file .split('\n') - // remove additional heading - .filter((line) => !line.includes('# @piwikpro/react-piwik-pro')) - // remove links suited for multi page documentation - .filter((line) => !line.includes('Exports')) + // remove the auto-generated index page heading + .filter((line) => !line.includes('## @piwikpro/react-piwik-pro')) // remove duplicated header .filter((line) => !line.includes('### Functions')) - // remove remove additional prefix - .map((line) => line.replace('Namespace: ', '')) - // increase heading level for the title + // turn the index page group heading into a table of contents heading + .map((line) => line.replace('### Namespaces', '### Table of contents')) + // restore the title heading level decreased by concat-md .map((line) => line.replace( '## Piwik PRO Library for React', '# Piwik PRO Library for React' ) ) + // drop the package-name prefix that concat-md derives from the module directory + .map((line) => line.replaceAll('react-piwik-pronamespaces', 'namespaces')) + // drop the rules typedoc puts between type-alias properties; we only want + // separators between whole sections + .filter((line) => line.trim() !== '***') + // add the section separator that hidePageHeader/hideBreadcrumbs removed + // after every section anchor (but not the readme anchor, followed by the title) + .map((line) => + line.startsWith('