Use Cases
Simple Page Tracking
If all you want is simple page tracking data sent to Google Analytics, Instant Analytics will do that for you automatically. Instant Analytics uses the Google Analytics 4 Protocol to send PageViews to your Google Analytics account the same way the Google Analytics Tracking Code JavaScript tag does.
In addition, Instant Analytics injects an instantAnalytics
object into your templates, which you can manipulate as you see fit, adding Google Analytics properties to be sent along with your PageView.
It has the added benefit of not having to load any JavaScript on the frontend to do this, which results in the following benefits:
- Your pages will render quicker in-browser, with no external resources loaded just for PageView tracking
- Pages will be tracked even if the client’s browser has JavaScript disabled or blocked
- JavaScript errors will not cause Google Analytics data to fail to be collected
Craft Commerce 4 or later Integration with Google Enhanced Ecommerce
If you are using Craft Commerce 4 or later, Instant Analytics will recognize this, and automatically send Google Enhanced Ecommerce data for the following actions:
- Add to Cart - When someone adds an item from your Craft Commerce store to their cart. This will include data for the Product or Variant that was added to the cart.
- Remove from Cart - When someone removes an item from your Craft Commerce store cart (requires Craft Commerce 4.0.0 or later). This will include data for the Product or Variant that was removed from the cart.
- Purchase - When someone completes a purchase in your Craft Commerce store. This will include all of the LineItems that were added to the cart, as well as the Order Reference, Revenue, Tax, Shipping, and Coupon Code used (if any).
Additionally, you can add simple Twig tags to your templates to track Product List Impressions, Product Impressions and track different steps of the Checkout process. In Google Analytics, you will be able to view detailed information on the sales from your Craft Commerce store, and other useful information such as where customers are abandoning their cart in the Checkout process.
Tracking Assets/Resources
Instant Analytics lets you track assets/resources that you can’t normally track. For instance, you may have a collection of PDF documents that you’d like to know when they are viewed.
Using a simple pageViewTrackingUrl(myAsset.url, myAsset.title)
or eventTrackingUrl(myAsset.url, "view-asset", {title: myAsset.title})
Twig function, Instant Analytics will generate a public URL that will register a PageView in Google Analytics for the asset/resource, and then display or download the asset/resource.
Tracking RSS Feeds
Getting actual tracking statistics on RSS feeds can be notoriously difficult, because they are often consumed by clients that are not web browsers, and therefor will not run JavaScript tracking code.
With Instant Analytics, if your RSS feed is a Twig template, accesses will automatically be tracked. Additionally, you can use the pageViewTrackingUrl(myAsset.url, myAsset.title)
or eventTrackingUrl(myAsset.url, "view-asset", {title: myAsset.title})
Twig functions to track individual episode accesses in Google Analytics.
Custom Tracking via Twig or Plugin
If your needs are more specialized, Instant Analytics will give your Twig templates or plugin full access to creating Event
objects that allows you to send arbitrary Google Analytics tracking data to Google Analytics.
You can do anything from customized PageViews to complicated Google Enhanced eCommerce tracking,
Brought to you by nystudio107