### Track App Installation in AppDelegate (Objective-C) Source: https://developers.piwik.pro/docs/sendapplicationdownload Example of how to configure the tracker and send the application download event within your application delegate's didFinishLaunchingWithOptions method. This ensures the event is captured on the first launch. ```Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Configure the tracker in your application delegate [PiwikTracker sharedInstanceWithSiteID:@"site-id" baseURL:[NSURL URLWithString:@"account-name"]]; [[PiwikTracker sharedInstance] sendApplicationDownload]; return YES; } ``` -------------------------------- ### Example: Track visible content impressions with custom interval Source: https://developers.piwik.pro/docs/trackvisiblecontentimpressions This example demonstrates how to track content block impressions on scroll events with a specific delay. The parameters set during initial setup cannot be changed later. ```Angular trackVisibleContentImpressions(true, 2000): void ``` ```Gatsby trackVisibleContentImpressions(true, 2000): void ``` ```Next.js trackVisibleContentImpressions(true, 2000): void ``` ```Nuxt trackVisibleContentImpressions(true, 2000): void ``` ```React trackVisibleContentImpressions(true, 2000): void ``` ```Vue trackVisibleContentImpressions(true, 2000): void ``` -------------------------------- ### Track Application Installs with Piwik PRO SDK Source: https://developers.piwik.pro/docs/using-piwik-pro-sdk Use this to track the initial installation of your application. This event is sent only once per installation and requires the Analytics module. ```kotlin TrackHelper.track().sendApplicationDownload().with(tracker) ``` ```java TrackHelper.track().sendApplicationDownload().with(getTracker()); ``` -------------------------------- ### Track App Installation in Flutter Source: https://developers.piwik.pro/docs/trackapplicationinstall-flutter-sdk Call this method to record an app installation event. It should be invoked when the app is first launched after installation. ```dart await FlutterPiwikPro.sharedInstance.trackApplicationInstall(); ``` -------------------------------- ### sendApplicationDownload() Source: https://developers.piwik.pro/docs/sendapplicationdownload Records an app installation event. This event is sent the first time the app is launched after installation. ```APIDOC ## sendApplicationDownload() ### Description Records an app installation event. This event is sent the first time the app is launched, once per installation. If a user installs your app but doesn't run it, the event is not sent. ### Syntax ```objectivec [[PiwikTracker sharedInstance] sendApplicationDownload]; ``` ### Example To track the installation of your app: ```objectivec - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Configure the tracker in your application delegate [PiwikTracker sharedInstanceWithSiteID:@"site-id" baseURL:[NSURL URLWithString:@"account-name"]]; [[PiwikTracker sharedInstance] sendApplicationDownload]; return YES; } ``` ### Notes It's best to add sendApplicationDownload() to your app delegate immediately after configuring the tracker because this event is only sent to the server once per app version. ``` -------------------------------- ### trackApplicationInstall() Source: https://developers.piwik.pro/docs/trackapplicationinstall-flutter-sdk Records app installations. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn't run it, the event is not sent. ```APIDOC ## trackApplicationInstall() ### Description Records app installations. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn't run it, the event is not sent. ### Syntax ```dart await FlutterPiwikPro.sharedInstance.trackApplicationInstall(); ``` ### Example To track the installation of your app: ```dart await FlutterPiwikPro.sharedInstance.trackApplicationInstall(); ``` ``` -------------------------------- ### Track App Installation in Kotlin Source: https://developers.piwik.pro/docs/trackapplicationinstall Use this snippet to record an app installation event. Ensure you have a Tracker instance available. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .applicationInstall() .with(tracker) ``` -------------------------------- ### Track Specific Download Example Source: https://developers.piwik.pro/docs/trackdownload This example demonstrates how to track a click on a specific file as a download. It requires initializing a tracker instance. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .sendDownload("https://example.com/paid-app.zip") .with(tracker) ``` ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .sendDownload("https://example.com/paid-app.zip") .with(tracker); ``` -------------------------------- ### Track App Installation in Java Source: https://developers.piwik.pro/docs/trackapplicationinstall Use this snippet to record an app installation event. Ensure you have a Tracker instance available. ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .applicationInstall() .with(tracker); ``` -------------------------------- ### sendApplicationDownload() Source: https://developers.piwik.pro/docs/tracksendapplicationdownload Records app installations. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn’t run it, the event is not sent. ```APIDOC ## track().sendApplicationDownload() ### Description Records app installations. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn’t run it, the event is not sent. ### Syntax ```kotlin Kotlin TrackHelper.track() .sendApplicationDownload() .with(tracker) ``` ```java Java TrackHelper.track() .sendApplicationDownload() .with(getTracker()); ``` ### Example To track the installation of your app: ```kotlin Kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .sendApplicationDownload() .with(tracker) ``` ```java Java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .sendApplicationDownload() .with(tracker); ``` ``` -------------------------------- ### killFrame() Example Source: https://developers.piwik.pro/docs/killframe-browser-js-api This example shows how to use the killFrame() method with the _paq push method. It is available in JavaScript. ```JavaScript _paq.push(["killFrame"]); ``` -------------------------------- ### Tracking Application Installs Source: https://developers.piwik.pro/docs/using-piwik-pro-sdk Track the installation of your application. This event is sent only once per application installation and is triggered on the first launch. ```APIDOC ## Tracking Application Installs ### Description Track installations of your application. This event is sent to the server only once per application installation. ### Method Signature `TrackHelper.track().sendApplicationDownload().with(tracker)` ### Request Example ```kotlin TrackHelper.track().sendApplicationDownload().with(tracker) ``` ```java TrackHelper.track().sendApplicationDownload().with(getTracker()); ``` ### Notes Application installation is only tracked during the first launch. In the case of the application being installed but not run, the app installation will not be tracked. ``` -------------------------------- ### Example Content Security Policy definition Source: https://developers.piwik.pro/docs/content-security-policy-csp An example CSP setup including default-src, script-src with nonce, connect-src, and img-src. Assumes specific website, container, and tracking domains, along with a nonce value. ```csp Content-Security-Policy: default-src 'self'; script-src 'self' INSERT_TRACKING_DOMAIN_VALUE 'nonce-nceIOfn39fn3e9h3sd'; connect-src 'self' INSERT_STATIC_RESOURCES_DOMAIN_VALUE INSERT_TRACKING_DOMAIN_VALUE; img-src 'self' INSERT_STATIC_RESOURCES_DOMAIN_VALUE INSERT_TRACKING_DOMAIN_VALUE; ``` -------------------------------- ### Example Usage of redirectFile() Source: https://developers.piwik.pro/docs/redirectfile-browser-js-api This example demonstrates how to use the redirectFile() method. Note that this method is deprecated and no longer recommended. ```javascript _paq.push(["redirectFile"]); ``` -------------------------------- ### Install Piwik PRO React Native SDK Source: https://developers.piwik.pro/docs/react-native-sdk Use npm to install the SDK. This command should be run in your React Native project directory. ```bash npm install @piwikpro/react-native-piwik-pro-sdk ``` -------------------------------- ### Example: Logging Download Classes Source: https://developers.piwik.pro/docs/getdownloadclasses This example demonstrates how to retrieve and log the list of CSS classes treated as downloads using the getDownloadClasses method within a JavaScript push to the tracker. ```javascript _paq.push([function () { console.log(this.getDownloadClasses()); }]); ``` -------------------------------- ### Track Outlink Example (Java) Source: https://developers.piwik.pro/docs/trackoutlink Example of tracking an outlink to 'https://example.com' using Java. Requires obtaining a tracker instance. ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .outlink("https://example.com") .with(tracker); ``` -------------------------------- ### track().applicationInstall() Source: https://developers.piwik.pro/docs/methods-android-sdk Tracks an application installation event. ```APIDOC ## track().applicationInstall() ### Description Tracks an event indicating that the application has been installed. ### Method Not applicable (SDK method) ### Endpoint Not applicable (SDK method) ### Parameters This method does not have explicitly documented parameters in the source. ### Request Example ```java // Example usage piwikProTracker.track().applicationInstall(); ``` ### Response This method typically returns void. The exact return type is not detailed in the source. ``` -------------------------------- ### trackAppInstall() Source: https://developers.piwik.pro/docs/trackappinstall-flutter-sdk Records app installations. This event is sent the first time the app is launched, once per installation. Note: This method is deprecated and trackApplicationInstall() should be used instead. ```APIDOC ## trackAppInstall() ### Description Records app installations. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn’t run it, the event is not sent. **Note:** This method is deprecated. Use `trackApplicationInstall()` instead. ### Syntax ```dart Flutter await FlutterPiwikPro.sharedInstance.trackAppInstall(); ``` ### Example To track the installation of your app: ```dart Flutter await FlutterPiwikPro.sharedInstance.trackAppInstall(); ``` ``` -------------------------------- ### Example: Track Goal with Value - Java Source: https://developers.piwik.pro/docs/trackgoal Example of tracking a goal with a specific ID and a conversion value of 20 in Java. Requires an initialized Tracker object. ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .goal("27ecc5e3-8ae0-40c3-964b-5bd8ee3da059") .revenue(20) .with(tracker); ``` -------------------------------- ### Track Outlink Example (Kotlin) Source: https://developers.piwik.pro/docs/trackoutlink Example of tracking an outlink to 'https://example.com' using Kotlin. Requires obtaining a tracker instance. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .outlink("https://example.com") .with(tracker) ``` -------------------------------- ### Install Piwik PRO JS Library with npm Source: https://developers.piwik.pro/docs/nextjs Install the Piwik PRO JavaScript library for Next.js using npm. ```sh npm install @piwikpro/next-piwik-pro ``` -------------------------------- ### JavaScript Example: Set React Provider Source: https://developers.piwik.pro/docs/settrackingsourceprovider This example demonstrates how to set the tracking source provider to 'react' with version '1.0.0' using JavaScript. ```javascript _paq.push(["setTrackingSourceProvider", "react", "1.0.0"]); ``` -------------------------------- ### Start New Session Source: https://developers.piwik.pro/docs/advanced-usage-react-native-sdk Manually starts a new user session. ```APIDOC ## startNewSession ### Description Manually starts a new user session. This is useful for explicitly defining session boundaries. ### Method Signature `await PiwikProSdk.startNewSession();` ### Request Example ```jsx React Native await PiwikProSdk.startNewSession(); ``` ``` -------------------------------- ### startNewSession() Source: https://developers.piwik.pro/docs/methods-react-native-sdk Starts a new user session. ```APIDOC ## startNewSession() ### Description Manually starts a new user session. This is useful for resetting the session context, for example, after a period of inactivity or a specific user action. ### Method `startNewSession()` ### Parameters This method does not take any parameters. ``` -------------------------------- ### Vue Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in Vue to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in Vue ### Code ```js VUE const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Track App Installation (Deprecated) Source: https://developers.piwik.pro/docs/trackappinstall-flutter-sdk This method is deprecated. Use trackApplicationInstall() instead. It records app installations, sending an event the first time the app is launched. ```Dart await FlutterPiwikPro.sharedInstance.trackAppInstall(); ``` -------------------------------- ### JavaScript Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in JavaScript to log the cross-domain linking parameter. ```APIDOC ## Example Usage in JavaScript ### Code ```js JavaScript _paq.push([function () { console.log(this.getCrossDomainLinkingUrlParameter()); }]); ``` ``` -------------------------------- ### Install JS library for Angular Source: https://developers.piwik.pro/docs/angular Install the Piwik PRO tracking library for Angular using npm or Yarn. ```sh npm install @piwikpro/ngx-piwik-pro ``` ```sh yarn add @piwikpro/ngx-piwik-pro ``` -------------------------------- ### Install @piwikpro/react-piwik-pro Source: https://developers.piwik.pro/docs/gatsby Install the Piwik PRO React library using npm. This is the first step before integrating tracking into your Gatsby application. ```sh npm install @piwikpro/react-piwik-pro ``` -------------------------------- ### trackApplicationInstall() Source: https://developers.piwik.pro/docs/methods-flutter-sdk Tracks an application install. ```APIDOC ## trackApplicationInstall() ### Description Tracks an application install. ### Method `trackApplicationInstall()` ### Parameters None ``` -------------------------------- ### Example: Track Goal with Value - Kotlin Source: https://developers.piwik.pro/docs/trackgoal Example of tracking a goal with a specific ID and a conversion value of 20 in Kotlin. Requires an initialized Tracker object. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .goal("27ecc5e3-8ae0-40c3-964b-5bd8ee3da059") .revenue(20) .with(tracker) ``` -------------------------------- ### Install Piwik PRO JS Library with Yarn Source: https://developers.piwik.pro/docs/nextjs Install the Piwik PRO JavaScript library for Next.js using Yarn. ```sh yarn add @piwikpro/next-piwik-pro ``` -------------------------------- ### startNewSession() Source: https://developers.piwik.pro/docs/methods-android-sdk Manually starts a new user session. ```APIDOC ## startNewSession() ### Description Manually initiates a new user session. This can be used to reset session tracking if needed. ### Method Not applicable (SDK method) ### Endpoint Not applicable (SDK method) ### Parameters This method does not have explicitly documented parameters in the source. ### Request Example ```java // Example usage piwikProTracker.startNewSession(); ``` ### Response This method typically returns void. The exact return type is not detailed in the source. ``` -------------------------------- ### Install React Piwik PRO Library Source: https://developers.piwik.pro/docs/react Install the Piwik PRO React library using npm or yarn. This is the first step to integrate data collection into your React application. ```sh npm install @piwikpro/react-piwik-pro ``` ```sh yarn add @piwikpro/react-piwik-pro ``` -------------------------------- ### Track Content Interaction Example Source: https://developers.piwik.pro/docs/trackinteraction Example of tracking a click interaction with a banner promoting a 'gravel bikes collection'. This requires a pre-initialized tracker instance. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .interaction("gravel bikes collection", "click") .piece("banner") .target("https://example.com/bikes/") .with(tracker) ``` ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .interaction("gravel bikes collection", "click") .piece("banner") .target("https://example.com/bikes/") .with(tracker); ``` -------------------------------- ### Example: Set 'plan type' Attribute Source: https://developers.piwik.pro/docs/audiencemanagersetprofileattribute-android-sdk This example demonstrates setting the 'plan type' attribute to 'premium' and sending it with an event. Note that the `add()` method is used here with empty values, which might be a placeholder or indicate no additional attributes. ```kotlin TrackHelper.track() .audienceManagerSetProfileAttribute("plan type", "premium") .add("", "") .with(tracker) ``` ```java TrackHelper.track() .audienceManagerSetProfileAttribute("plan type", "premium") .add("", "") .with(getTracker()); ``` -------------------------------- ### trackApplicationInstall Source: https://developers.piwik.pro/docs/trackapplicationinstall-react-native-sdk Records app installations. The event is sent the first time the app is launched, once per app version. If a user installs your app but doesn't run it, the event is not sent. ```APIDOC ## trackApplicationInstall() ### Description Records app installations. The event is sent the first time the app is launched, once per app version. If a user installs your app but doesn't run it, the event is not sent. ### Method ```jsx React Native await PiwikProSdk.trackApplicationInstall(); ``` ### Example ```jsx React Native await PiwikProSdk.trackApplicationInstall(); ``` ``` -------------------------------- ### Install Log Analytics Script Manually Source: https://developers.piwik.pro/docs/web-log-analytics Manually install the log analytics script by downloading the Python file and making it executable. ```sh curl https://raw.githubusercontent.com/PiwikPRO/log-analytics/master/piwik_pro_log_analytics/import_logs.py > import_logs.py chmod +x import_logs.py ``` -------------------------------- ### Enable App Installation Tracking Source: https://developers.piwik.pro/docs/progressive-web-applications-integration Use this method to track the app installation event as a custom event in Piwik PRO Analytics. ```jsx import PiwikPro from '@piwikpro/pwa-piwik-pro'; PiwikPro.enableInstallTracking(); ``` -------------------------------- ### Install PiwikPROSDK via CocoaPods Source: https://developers.piwik.pro/docs/ios-sdk Add this line to your Podfile to install the Piwik PRO SDK. Replace VERSION with the latest release name. ```ruby pod 'PiwikPROSDK', '~> VERSION' ``` -------------------------------- ### startNewSession Source: https://developers.piwik.pro/docs/methods-ios-sdk Manually starts a new session. ```APIDOC ## startNewSession() ### Description Manually initiates a new user session. This can be useful in specific scenarios where automatic session detection is not desired. ### Method Objective-C/Swift method call ### Endpoint N/A (SDK method) ### Parameters N/A ### Request Example ```objc [[PiwikTracker sharedInstance] startNewSession]; ``` ```swift PiwikTracker.sharedInstance.startNewSession() ``` ### Response #### Success Response N/A (SDK method, no direct response) #### Response Example N/A ``` -------------------------------- ### Example: Disable Link Tracking Source: https://developers.piwik.pro/docs/disablelinktracking This example shows how to disable the automatic tracking of downloads and outlinks by pushing the disableLinkTracking command to the _paq array. ```javascript _paq.push(["disableLinkTracking"]); ``` -------------------------------- ### Install Nuxt Piwik PRO Library Source: https://developers.piwik.pro/docs/nuxt Install the JS library for Nuxt using npm. This is the first step to integrating Piwik PRO into your Nuxt project. ```sh npm install @piwikpro/nuxt-piwik-pro ``` -------------------------------- ### Track App Installation - React Native Source: https://developers.piwik.pro/docs/trackapplicationinstall-react-native-sdk Use this method to record app installations. The event is sent the first time the app is launched, once per app version. Ensure the app is run for the event to be sent. ```jsx await PiwikProSdk.trackApplicationInstall(); ``` -------------------------------- ### Get Profile Attributes in Objective-C (Example) Source: https://developers.piwik.pro/docs/audiencemanagergetprofileattributes-ios-sdk This is an example of how to get profile attributes using the audienceManagerGetProfileAttributes method. Access is limited to attributes that have been granted. ```Objective-C [[PiwikTracker sharedInstance] audienceManagerGetProfileAttributes:^(NSDictionary *attributes, NSError * _Nullable errorData) { // Do something with the attribute list }]; ``` -------------------------------- ### Get Custom Dimension Value (Angular) Source: https://developers.piwik.pro/docs/getcustomdimension-deprecated This example shows how to get a custom dimension value in Angular. The getCustomDimensionValue() method is preferred over the deprecated getCustomDimension(). ```typescript getCustomDimensionValue(customDimensionId): Promisea ``` -------------------------------- ### Example: Get Custom Dimension Value Source: https://developers.piwik.pro/docs/getcustomdimensionvalue This example demonstrates how to retrieve the value for a custom dimension with ID 1 using the _paq.push method. The retrieved value is then logged to the console. ```JavaScript _paq.push([ function () { console.log(this.getCustomDimensionValue(1)); }, ]); ``` ```Angular getCustomDimensionValue(1): Promise ``` ```Gatsby getCustomDimensionValue(1): Promise ``` ```Next.js getCustomDimensionValue(1): Promise ``` ```Nuxt getCustomDimensionValue(1): Promise ``` ```React getCustomDimensionValue(1): Promise ``` ```Vue getCustomDimensionValue(1): Promise ``` -------------------------------- ### Example: Track Content Impression Source: https://developers.piwik.pro/docs/trackcontentimpression Provides an example of how to use trackContentImpression to log a specific content block's impression. This is useful for analyzing content engagement. ```javascript _paq.push([ "trackContentImpression", "bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/", ]); ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` ```typescript trackContentImpression("bike-jump-video", "https://example.com/big-jump.mp4", "https://example.com/bikes/"): void ``` -------------------------------- ### Start New Session in Kotlin and Java Source: https://developers.piwik.pro/docs/advanced-usage-android-sdk Manually start a new session when sending an event. Optionally preserve campaign data, deep link data, custom dimensions, and custom variables. ```kotlin tracker.startNewSession(preserveSessionParameters) ``` ```java tracker.startNewSession(Boolean preserveSessionParameters); ``` -------------------------------- ### Example: Track Bike Collection Impression - Java Source: https://developers.piwik.pro/docs/trackimpression Example of tracking a specific content impression for a 'gravel bikes collection' in Java. This includes the content name, piece (banner), and target URL. ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .impression("gravel bikes collection") .piece("banner") .target("https://example.com/bikes/") .with(tracker); ``` -------------------------------- ### Example of getting items added to the cart Source: https://developers.piwik.pro/docs/getecommerceitems-deprecated Use this snippet to retrieve items currently in the e-commerce cart. Remember that cart data is not stored locally and will be lost on page reload. ```javascript _paq.push([ function () { console.log(this.getEcommerceItems()); }, ]); ``` -------------------------------- ### trackAppInstall() Source: https://developers.piwik.pro/docs/methods-flutter-sdk Tracks an application install. This method is deprecated. ```APIDOC ## trackAppInstall() ### Description Tracks an application install. This method is deprecated. ### Method `trackAppInstall()` ### Parameters None ``` -------------------------------- ### Track Content Impression Example Source: https://developers.piwik.pro/docs/trackimpression-react-native-sdk An example demonstrating how to track a content impression for a specific collection, including piece, target, visit custom variables, and custom dimensions. This requires content tracking to be enabled in your Piwik PRO Tag Manager. ```jsx const options = { piece: 'banner', target: 'https://example.com/bikes/', visitCustomVariables: { 1: { name: 'name', value: 'value' } }, customDimensions: { 1: 'value', 2: 'value' }, }; await PiwikProSdk.trackImpression('gravel bikes collection', options); ``` -------------------------------- ### Example: Track Sign-up Button Click in Java Source: https://developers.piwik.pro/docs/trackevent Send a custom event when a user clicks a sign-up button, including its path, name, and a specific value. Requires a valid Tracker instance. ```java Tracker tracker = ((PiwikApplication) getApplication()).getTracker(); TrackHelper.track() .event("Clicks", "Button") .path("/main/signup") .name("Sign up") .value(100) .with(tracker); ``` -------------------------------- ### React Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in React to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in React ### Code ```js React const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Nuxt Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in Nuxt to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in Nuxt ### Code ```js Nuxt const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Next.js Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in Next.js to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in Next.js ### Code ```js Next.js const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Gatsby Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in Gatsby to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in Gatsby ### Code ```js Gatsby const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Angular Example Source: https://developers.piwik.pro/docs/getcrossdomainlinkingurlparameter Example of how to use getCrossDomainLinkingUrlParameter() in Angular to retrieve the cross-domain linking parameter. ```APIDOC ## Example Usage in Angular ### Code ```js Angular const domainLinkingUrlParameters = await CrossDomainTracking.getCrossDomainLinkingUrlParameter(); ``` ``` -------------------------------- ### Track Application Install Source: https://developers.piwik.pro/docs/using-flutter-sdk Tracks installations of your application. This event is sent only once per application version. ```APIDOC ## trackApplicationInstall ### Description Tracks installations of your application. This event is sent to the server only once per application version. ### Method Signature `Future trackApplicationInstall()` ### Request Example ```dart await FlutterPiwikPro.sharedInstance.trackApplicationInstall(); ``` ``` -------------------------------- ### Create and Track a Product Addition (Objective-C) Source: https://developers.piwik.pro/docs/ecommerceaddtocart-ios-sdk This example demonstrates how to create a product object with various attributes and then add it to the cart using ecommerceAddToCart. Custom dimensions can also be included. ```Objective-C Product *product = [Product productWithSku:@"craft-311" name:@"Unicorn Iron on Patch" category:@[@"Crafts & Sewing", @"Toys"] price:@"49.90" quantity:@3 brand:@"DMZ" variant:@"blue" customDimensions:@{@1: @"coupon-2020", @2: @"20%"}]; EcommerceProducts *products = [[EcommerceProducts alloc] init]; [products addProduct:product]; [[PiwikTracker sharedInstance] ecommerceAddToCart:products]; ``` -------------------------------- ### Track an E-commerce Order with Options Source: https://developers.piwik.pro/docs/trackecommerceorder-react-native-sdk This example demonstrates how to track a complete e-commerce order, including detailed product information, order totals, and custom options like discounts, shipping, tax, and currency. Ensure all required parameters and optional fields are correctly populated. ```jsx const options: TrackEcommerceOrderOptions = { visitCustomVariables: { 1: { name: 'name', value: 'value' } }, customDimensions: { 1: 'value', 2: 'value' }, discount: 'discount', shipping: 'shipping', subTotal: 'subTotal', tax: 'tax', currencyCode: 'currencyCode', }; const ecommerceProduct: EcommerceProduct[] = [ { sku: 'sku', name: 'name', category: ['category'], price: 'price', quantity: quantity, brand: 'brand', variant: 'variant', customDimensions: { 1: 'value', 2: 'value', }, }, ]; let grandTotal: String = 'grandTotal'; let orderId: String = 'orderId'; await PiwikProSdk.trackEcommerceOrder(orderId, grandTotal, ecommerceProduct, options); ``` ```jsx const options: TrackEcommerceOrderOptions = { visitCustomVariables: { 1: { name: 'name', value: 'value' } }, customDimensions: { 1: 'value', 2: 'value' }, discount: '18', shipping: '60', subTotal: '120', tax: '39.6', currencyCode: 'EUR', }; const ecommerceProduct: EcommerceProduct[] = [ { sku: 'craft-311', name: 'Unicorn Iron on Patch', category: ['Crafts & Sewing', 'Toys', 'Cosmetics'], price: '49,9089', quantity: 3, brand: 'DMZ', variant: 'blue', customDimensions: { 1: 'coupon-2020', 2: '20%', }, }, ]; let grandTotal: String = '10000'; let orderId: String = 'order-3415'; await PiwikProSdk.trackEcommerceOrder(orderId, grandTotal, ecommerceProduct, options); ``` -------------------------------- ### sendEventWithCategory Objective-C Example Source: https://developers.piwik.pro/docs/sendeventwithcategory Example of sending a custom event when a user clicks on a signup button. ```APIDOC ## sendEventWithCategory Objective-C Example ### Description To send a custom event when a user clicks on a signup button on /main/signup and assign the value 100 to the event. ### Method Objective-C method call ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```objectivec [[PiwikTracker sharedInstance] sendEventWithCategory:@"Clicks" action:@"Button" name:@"Sign up" value:@100 path:@"/main/signup"]; ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Initialize Piwik PRO SDK Source: https://developers.piwik.pro/docs/react Initializes the Piwik PRO SDK with your site ID and account address. Optionally, you can provide a custom nonce and dataLayerName. ```APIDOC ## Initialize Piwik PRO SDK ### Description Initializes the Piwik PRO SDK with your site ID and account address. This method ensures that collected data is sent to your Piwik PRO account and reported as a corresponding site or app. You can also configure a custom nonce and data layer name. ### Method `PiwikPro.initialize(siteId, accountAddress, options)` ### Parameters #### Path Parameters - **siteId** (string) - Required - The ID of your Piwik PRO site. - **accountAddress** (string) - Required - The URL of your Piwik PRO account (e.g., `https://example.piwik.pro/`). - **options** (object) - Optional - Configuration options. - **nonce** (string) - Optional - A nonce string for security. - **dataLayerName** (string) - Optional - The name of the data layer to use. ### Request Example ```jsx import PiwikPro from '@piwikpro/react-piwik-pro'; PiwikPro.initialize('site-id', 'https://example.piwik.pro/', { nonce: 'nonce-string', dataLayerName: 'my-data-layer' }); ``` ``` -------------------------------- ### Set Visit Variable and Track Screen View (Java) Source: https://developers.piwik.pro/docs/trackvisitvariables-android-sdk Example of setting a custom visit variable and then tracking a screen view with it using Java. Ensure the tracker is properly initialized. ```java TrackHelper.track() .visitVariables(1, "age", "25") TrackHelper.track() .screen("example/welcome") .title("Welcome") .with(getTracker()); ``` -------------------------------- ### setEcommerceView JavaScript Example Source: https://developers.piwik.pro/docs/setecommerceview-deprecated Example of using setEcommerceView() in JavaScript to track a product view. This method should be followed by trackPageView(). ```APIDOC ## setEcommerceView ### Description Tracks product views and category views. This method must be followed by `trackPageView()`. ### Syntax ```js setEcommerceView([productSKU[, productName[, productCategory[, productPrice]]]]) ``` ### Parameters #### Path Parameters - **productSKU** (string, optional) - The stock-keeping unit of the product. - **productName** (string, optional) - The name of the product. - **productCategory** (string | array, optional) - The category of the product. Can be an array of up to 5 categories. - **productPrice** (number, optional) - The price of the product. ### Request Example ```js paq.push([ "setEcommerceView", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]); _paq.push(["trackPageView"]); ``` ### Notes This method does not send data directly; `trackPageView()` must be called afterward. ``` -------------------------------- ### Initialize Piwik PRO in React App Source: https://developers.piwik.pro/docs/react Initialize the Piwik PRO library with your site ID and account address. Optional parameters like nonce and dataLayerName can also be provided. This setup is required before tracking any data. ```jsx import PiwikPro from '@piwikpro/react-piwik-pro'; PiwikPro.initialize('site-id', 'account-address',{ nonce: 'nonce-string', dataLayerName: 'my-data-layer' }); ReactDOM.render(, document.getElementById('root')) ``` -------------------------------- ### setCustomRequestProcessing JavaScript Example Source: https://developers.piwik.pro/docs/setcustomrequestprocessing This example demonstrates how to use setCustomRequestProcessing in JavaScript to modify the query string by replacing 'rec=1' with 'rec=0'. ```APIDOC ## setCustomRequestProcessing ### Description Allows you to set up a function that will access and modify any query string before it will be sent as a request. ### Method Signature ```js JavaScript setCustomRequestProcessing(queryProcessingFunction) ``` ### Parameters #### queryProcessingFunction (function) - Required: Yes - Description: A function that accepts a query string and returns another query string. #### queryProcessingFunction Parameters ##### originalQuery (string) - Description: Query string that will be sent by tracker if not modified. Example: `ping=6&idsite=45e07cbf-c8b3-42f3-a6d6-a5a176f623ef&rec=1&r=123456&h=12&m=0&s=0&url=https%3A%2F%2Fexample.com%2F&_id=1234567890abcdef&_idts=1660552750&_idvc=87&_idn=0&_viewts=1660757889&send_image=0&ts_n=jstc_tm&ts_v=1.2.1&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=0&java=0&gears=0&ag=0&cookie=1&res=1680x1050&dimension1=Disabled&_ms=318&pv_id=abcdE1` ### Return Value - Type: string - Description: Modified query string that will be sent by the tracker. If the returned value is an empty string, then no request will be sent. ### Example ```js JavaScript _paq.push([ "setCustomRequestProcessing", function (query) { var modifiedQuery = query.replace("rec=1", "rec=0"); return modifiedQuery; }, ]); ``` ``` -------------------------------- ### Send Application Download Event (Objective-C) Source: https://developers.piwik.pro/docs/sendapplicationdownload Call this method to record an app installation. It's best to add it to your app delegate immediately after configuring the tracker, as this event is sent only once per app version. ```Objective-C [[PiwikTracker sharedInstance] sendApplicationDownload]; ``` -------------------------------- ### Example Usage Source: https://developers.piwik.pro/docs/setvisitoridlifetime-react-native-sdk Demonstrates how to set the visitor ID lifetime to 30 days. ```APIDOC ## Example To set the visitor ID lifetime to 30 days (30 * 24 * 60 * 60 seconds): ```jsx React Native await PiwikProSdk.setVisitorIDLifetime(30 * 24 * 60 * 60); ``` ``` -------------------------------- ### Example: Track Sign-up Button Click in Kotlin Source: https://developers.piwik.pro/docs/trackevent Send a custom event when a user clicks a sign-up button, including its path, name, and a specific value. Requires a valid Tracker instance. ```kotlin val tracker: Tracker = (application as PiwikApplication).tracker TrackHelper.track() .event("Clicks", "Button") .path("/main/signup") .name("Sign up") .value(100) .with(tracker) ``` -------------------------------- ### Install Log Analytics Script via Pip Source: https://developers.piwik.pro/docs/web-log-analytics Install the log analytics script using pip for easy integration into your Python environment. ```sh pip install piwikpro-log-analytics ``` -------------------------------- ### startNewSession() Method Source: https://developers.piwik.pro/docs/startnewsession The startNewSession() method is used to begin a new user session. This is useful for tracking distinct user interactions or visits. ```APIDOC ## startNewSession() ### Description Starts a new session. ### Syntax ```kotlin Kotlin tracker.startNewSession() ``` ```java Java getTracker().startNewSession(); ``` ### Example ```kotlin Kotlin tracker.startNewSession() ``` ```java Java getTracker().startNewSession(); ``` ``` -------------------------------- ### Angular Example: Set React Provider Source: https://developers.piwik.pro/docs/settrackingsourceprovider This example shows how to set the tracking source provider to 'react' with version '1.0.0' in an Angular environment. ```javascript Miscellaneous.setTrackingSourceProvider("react", "1.0.0") ``` -------------------------------- ### Set Visit Variable and Track Screen View (Kotlin) Source: https://developers.piwik.pro/docs/trackvisitvariables-android-sdk Example of setting a custom visit variable and then tracking a screen view with it using Kotlin. Ensure the tracker is properly initialized. ```kotlin TrackHelper.track() .visitVariables(1, "age", "25") TrackHelper.track() .screen("example/welcome") .title("Welcome") .with(tracker) ``` -------------------------------- ### Setup with nonce for CSP Source: https://developers.piwik.pro/docs/angular Pass a nonce value during NgxPiwikProModule initialization to allow-list specific inline scripts, avoiding the CSP 'unsafe-inline' directive. ```ts import { NgxPiwikProModule } from "@piwikpro/ngx-piwik-pro"; @NgModule({ declarations: [AppComponent], imports: [ BrowserModule, NgxPiwikProModule.forRoot("container-id", "container-url", {nonce: "nonce-hash"}), // ^^^^^^^^^^^^^^^^^^^^^^^ ], providers: [], bootstrap: [AppComponent], }) export class AppModule {} ``` -------------------------------- ### Example: Set maxAgeOfQueuedEvents to 12 hours in Objective-C Source: https://developers.piwik.pro/docs/maxageofqueuedevents This example shows how to set the maximum age of queued events to 12 hours using Objective-C. ```APIDOC ## Example: Set maxAgeOfQueuedEvents to 12 hours ### Description Sets the time limit for storing events in local storage to 12 hours. ### Method Property Assignment ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```objectivec [PiwikTracker sharedInstance].maxAgeOfQueuedEvents = 12 * 60 * 60; ``` ### Response N/A (Property assignment) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Track a product view using setEcommerceView Source: https://developers.piwik.pro/docs/setecommerceview-deprecated This example demonstrates how to track a product view using the setEcommerceView method. Remember that this method must be followed by trackPageView() to send the data. ```javascript paq.push([ "setEcommerceView", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]); _paq.push(["trackPageView"]); ``` -------------------------------- ### Track a specific goal with value and currency Source: https://developers.piwik.pro/docs/trackgoal-react-native-sdk This example demonstrates tracking a goal with a specific ID, revenue value, and currency code. It also includes custom visit variables and dimensions. ```jsx const options = { revenue: 20, currencyCode: 'USD', visitCustomVariables: { 1: { name: 'name', value: 'value' } }, customDimensions: { 1: 'value', 2: 'value' }, }; await PiwikProSdk.trackGoal('27ecc5e3-8ae0-40c3-964b-5bd8ee3da059', options); ``` -------------------------------- ### Configure the Piwik PRO Tracker Source: https://developers.piwik.pro/docs/flutter-sdk Initialize the Piwik PRO tracker by providing your account's base URL and the site/app ID. This step is crucial before making any tracking calls. ```dart await FlutterPiwikPro.sharedInstance.configureTracker(baseURL: 'https://example.piwik.pro/', siteId: '01234567-89ab-cdef-0123-456789abcdef'); ``` -------------------------------- ### trackApplicationInstall Source: https://developers.piwik.pro/docs/using-react-native-sdk Tracks an application install. This event is sent only once per application version. ```APIDOC ## trackApplicationInstall ### Description Tracks an application install. This event is sent to the server only once per application version. ### Method `PiwikProSdk.trackApplicationInstall()` ``` -------------------------------- ### Install Vue.js Piwik PRO Library with npm Source: https://developers.piwik.pro/docs/vue Use this command to add the Piwik PRO Vue.js library to your project via npm. ```sh npm install @piwikpro/vue-piwik-pro ``` -------------------------------- ### Start a New Session in Swift Source: https://developers.piwik.pro/docs/startnewsession-ios-sdk Call this method to begin a new session. Ensure the PiwikTracker.sharedInstance is initialized. ```Swift PiwikTracker.sharedInstance.startNewSession() ``` -------------------------------- ### Initialize PiwikPro Source: https://developers.piwik.pro/docs/gatsby Initialize the PiwikPro library with your container ID and URL. This must be called before any other tracking functions. ```APIDOC ## Initialize PiwikPro ### Description Initializes the Piwik PRO tracking library with the provided container ID and URL. This function must be called before any other tracking functions can record data. ### Method `PiwikPro.initialize(containerId, containerUrl, options)` ### Parameters #### Path Parameters - **containerId** (string) - Required - The ID of your Piwik PRO container. - **containerUrl** (string) - Required - The URL of your Piwik PRO instance (e.g., `https://example.piwik.pro/`). - **options** (object) - Optional - Configuration options. - **nonce** (string) - Optional - A nonce string to be used for script security. - **dataLayerName** (string) - Optional - The custom name for the data layer. ### Request Example ```jsx import PiwikPro from '@piwikpro/react-piwik-pro'; PiwikPro.initialize('your-container-id', 'https://your-piwik-pro-instance.com/'); ``` ### Request Example with Options ```jsx import PiwikPro from '@piwikpro/react-piwik-pro'; PiwikPro.initialize('your-container-id', 'https://your-piwik-pro-instance.com/', { nonce: 'your-nonce-string', dataLayerName: 'customDataLayer' }); ``` ``` -------------------------------- ### Objective-C Example for setCustomVariableForIndex Source: https://developers.piwik.pro/docs/setcustomvariableforindex-ios-sdk Example of setting a custom variable with index 1, name 'Rating', value '5', and scope 'CustomVariableScopeAction' in Objective-C. This method is deprecated. ```objectivec [[PiwikTracker sharedInstance] setCustomVariableForIndex:1 name:@"Rating" value:@"5" scope:CustomVariableScopeAction]; ``` -------------------------------- ### Track Download URL Syntax Source: https://developers.piwik.pro/docs/trackdownload Use this syntax to send a download event with the specified URL. Ensure you have the TrackHelper and a tracker instance available. ```kotlin TrackHelper.track() .sendDownload("downloadURL") .with(tracker) ``` ```java TrackHelper.track() .sendDownload("downloadURL") .with(getTracker()); ``` -------------------------------- ### Remove Ecommerce Item Example Source: https://developers.piwik.pro/docs/removeecommerceitem-deprecated This example demonstrates how to use the removeEcommerceItem method with a specific product SKU. Note that this method is deprecated and does not send data to Piwik PRO. ```javascript _paq.push(["removeEcommerceItem", "584340"]); ``` ```typescript removeEcommerceItem(584340): void ``` ```javascript removeEcommerceItem(584340): void ``` ```javascript removeEcommerceItem(584340): void ``` ```javascript removeEcommerceItem(584340): void ``` ```javascript removeEcommerceItem(584340): void ``` ```javascript removeEcommerceItem(584340): void ``` -------------------------------- ### Disable Site Inspector Setup Source: https://developers.piwik.pro/docs/setsiteinspectorsetup Use this JavaScript snippet to disable the Site Inspector setup. This prevents the Chrome extension from identifying the tracker instance and site ID. ```JavaScript _paq.push(["setSiteInspectorSetup", false]); ``` -------------------------------- ### Set up Piwik PRO Tracker in AppDelegate Source: https://developers.piwik.pro/docs/ios-sdk Configure the Piwik PRO tracker in your application delegate by providing your site ID and account address. ```objectivec #import - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Configure the tracker in your application delegate [PiwikTracker sharedInstanceWithSiteID:@"site-id" baseURL:[NSURL URLWithString:@"account-address"]]; return YES; } ```