Data Whimsy
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum

Without the dashboard

The top slot of your browser can send requests to Tracking API & Reporting API
The command line of your browser can accept direct Matomo input (e.g. the PHP ./console command).
On this page are a variety of things you can do without ever touching the visual dashboard (Matomo GUI)

Ecommerce methods in Matomo (Javascript)

11/7/2024

0 Comments

 
Question:
In Matomo, which methods are available in Ecommerce to pass information to Matomo, from the data layer of the browser?

Answer:
In Matomo, to track Ecommerce data from the data layer of the browser, several JavaScript methods are available within the Matomo tracking API. These methods enable you to pass product and order-related information efficiently. Here's an overview of the key methods used for Ecommerce tracking:

### 1. **Ecommerce Tracking Methods**
   - **`trackEcommerceOrder(orderId, grandTotal, subTotal, tax, shipping, discount)`**
     - This method is used to track an order after a user completes a purchase. You should call this method with details such as the order ID, total amount, and any applicable taxes, shipping, and discounts.
     - **Parameters:**
       - `orderId`: Unique identifier for the order.
       - `grandTotal`: The total amount of the order (including tax, shipping, etc.).
       - `subTotal`: (Optional) Total value of the items in the order, excluding tax and shipping.
       - `tax`: (Optional) Total tax for the order.
       - `shipping`: (Optional) Shipping cost for the order.
       - `discount`: (Optional) Discount applied to the order.

   - **`addEcommerceItem(sku, name, category, price, quantity)`**
     - This method is used to add items to the cart or an order. Each item added is associated with details such as SKU, product name, category, price, and quantity.
     - **Parameters:**
       - `sku`: The unique identifier for the product (e.g., product code).
       - `name`: (Optional) The name of the product.
       - `category`: (Optional) Category name or hierarchy (e.g., "Clothing > Men > Shirts").
       - `price`: (Optional) Price of the product.
       - `quantity`: (Optional) Quantity of the product being purchased.

   - **`trackEcommerceCartUpdate(grandTotal)`**
     - This method is used to update the cart's total value. Call this whenever the cart's content changes (e.g., adding or removing products).
     - **Parameters:**
       - `grandTotal`: The updated total amount of the cart.

### 2. **Implementation Tips**
   - **Data Layer Integration**: To use these methods with data from a data layer (like in a tag management system), you typically access the data layer variables and pass the values to these methods.
   - **Order of Execution**: Ensure that `addEcommerceItem` is called before `trackEcommerceOrder` to associate all items with the order.
   - **Asynchronous Loading**: If using Matomo asynchronously, make sure that the data layer information is loaded and accessible before calling these methods.

### 3. **Example Usage**
```javascript
// Example: Tracking a purchase with multiple items
_paq.push(['addEcommerceItem',
    "12345", // SKU
    "Running Shoes", // Product name
    "Sports > Running", // Category
    99.95, // Price
    2 // Quantity
]);

_paq.push(['addEcommerceItem',
    "67890", // SKU
    "Running Shorts", // Product name
    "Sports > Running", // Category
    49.95, // Price
    1 // Quantity
]);

// Track the order
_paq.push(['trackEcommerceOrder',
    "ORDER123", // Order ID
    249.85, // Grand Total
    199.85, // Sub Total
    20.00, // Tax
    30.00, // Shipping
    0.00 // Discount
]);
```

These methods should be called in sequence based on the Ecommerce events occurring on your website, like adding items to the cart or completing a purchase.h
h
h

0 Comments

Examples of Matomo's database table matomo_archive_invalidations

11/4/2024

0 Comments

 
How does Matomo keep track of what to process?
The core:archive looks for invalidations in the database table called matomo_archive_invalidations.

Four sequential screenshots of the invalidations table in the MySQL database.
1. The table is empty becuase I did:
   mysql> TRUNCATE  matomo_archive_invalidations;
   mysql> SELECT count(*) FROM  matomo_archive_invalidations;
2. Then I told Matomo that all the reports are stale for today and yesterday.
This second screenshot is after this CLI command
   CLI: sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --sites=1,2  --dates="2024-11-03",today --periods=day,week,month"
    mysql> SELECT count(*) FROM  matomo_archive_invalidations;
3. Then I ran the archiver, telling it to not calculate the archiving of any segments.
The syntax in Matomo for archiving WITHOUT doing segments is like this:
$ sudo su www-data -s /bin/bash -c  "php  -d memory_limit=2G   /var/www/littlefurnace.com/matomo/console core:archive --skip-all-segments --force-idsites=1,2"
4. The fourth screenshot is of the database after archiving the segments using the following command, similar to the command in 3:
  $ sudo su www-data -s /bin/bash -c  "php  -d memory_limit=2G   /var/www/littlefurnace.com/matomo/console core:archive  --force-idsites=1,2"


Picture
Picture
Picture
Picture

What happens in the matomo_archive_invalidations table when you invalidate?

When you do one simple command, invalidate a year, for one site (not any days nor months), what is created in the table is actually a series of rows, presumably each one a different recipe which needs to be performed on your one site, for the year.  Recall that Matomo builds the data of a YEAR by adding up the reports for the individual DAYS.

Run this in the CLI
sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --sites=1  --periods=year --dates='2024-11-02','2024-11-02'"

You'll create these lines in the invalidations queue (which is stored in the db as matomo_archive_invalidations

Picture
0 Comments

    Author

    Evan Genest

    Archives

    November 2024
    August 2024
    May 2024
    March 2024
    February 2024
    November 2023
    October 2023
    September 2023
    August 2023

    Categories

    All

Powered by Create your own unique website with customizable templates.
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum