UGC Techdocs
  • Introduction
  • Guides
    • Analytics
      • Tracking UGC on Adobe Analytics
      • Tracking Widget interactions with Google Analytics
    • Direct Uploader
      • How to add Custom Data to Direct Uploader
      • How to capture Custom Data on Direct Uploader
      • How to automatically tag data on Direct Uploader
      • How to Customize error messages on Direct Uploader
      • How to Track Direct Uploader form submissions with Google Analytics (Universal & GA 4)
    • Data Templates
      • Creating a Data Template
    • Rights via Registration
      • Capture Custom Data on Rights by Registration Form
      • Styling Rights via Registration Form
    • REST API
      • Caching REST API results for optimization
      • Posting content into Nosto via Tile API
      • Posting images into Nosto via Tile API
    • Onsite Widgets (2.0)
      • Blank Canvas
        • How to Use the Blank Canvas to Create a Twitter Count Widget
        • Creating an Auto-Scrolling Carousel using Blank Canvas
        • Creating Gallery Widget by Using the Blank Canvas Widget
        • Creating a simple Hover effect using Blank Canvas
        • Creating a Word Cloud using Blank Canvas
        • Creating Your Widget by Using the Blank Canvas
      • Bind your own Events
      • Creating a Grid Widget from Waterfall
      • Create a Q&A Widget using Data Templates
      • Displaying a Widget in a Mobile App
      • Dynamically Specify Products to Display in Widget
      • Dynamically specify what Tile to display in a Widget
      • How to add a title / subtitle to a widget
      • How to localize the load more button on widgets
      • How to overlay existing Google Map with the UGC Map Widget
      • How to use Filter and search in a Widget
      • How to change click on inline tile behaviour to redirect to PDP in a Widget
      • Styling cross-sellers on Grid and Carousel Widgets
      • How to Load External JS and CSS into Widgets
      • Profiling Widget Performance
      • Re-targeting with Widgets and Facebook Pixel
      • Render Widget filters dynamically
      • Styling Carousel Widget
      • Styling Grid Widget
      • Styling Masonry Widget
      • Styling Waterfall Widget
      • Styling Widget Expanded Tile
      • Styling Widget Shopspots
      • Using Web Fonts in Widgets
    • Digital Screens
      • Customizing Carousel Event Screen
      • Customizing Mosaic Event Screen
      • Customizing Scrollwall Event Screen
      • Customizing the Mosaic Event Screen to Have 9 Even Tiles
    • Email
      • Adding Location to an Email Tile
      • Styling the Email Widget
    • Integrations
      • DoubleClick
        • UGC Ads with Nosto and Google DoubleClick
      • Zapier
        • Consuming UGC Webhooks via Zapier
      • Mailchimp
        • Bring Social Content into a Mailchimp Campaign
    • Webhooks
      • Trigger notifications when content is in the moderation queue
  • Widgets
  • API Docs
    • JavaScript API
      • Widgets
        • Introduction
        • API Reference for Content Widgets
        • API Reference for Blank Canvas
        • API Reference for Map Widget
      • Digital Screens
        • Introduction
        • API Reference
    • Content API
      • Reference
    • REST API
      • Reference
        • Filters API
        • Moderation Views API
        • Tags API
        • Terms API
        • Tiles API
        • Users API
        • Widgets API
        • Automation Rules API
        • REST API Reference Widgets style and config
      • Best Practices
    • Webhooks
  • Enterprise Tools
    • Automation Rules
      • Triggers
      • Actions
      • Samples
    • Data Templates
    • User Access Control (UAC)
    • Single Sign On (SSO)
    • Enterprise Admin User Interface (EAUI)
    • Zapier
  • Commerce Tools
    • Product Feeds
    • Widget Implementation
    • Reporting
    • Integrations
      • Google Tag Manager
      • Magento
      • SalesForce Commerce Cloud
      • Shopify
      • Shopify Add To Cart
        • Global Variant Mapping for Add to Cart
        • Customise Add to Cart Widget Experience
  • Analytics
    • Google Analytics 4
      • Getting Started
      • Widgets Events
      • E-commerce Events
      • Email Events
  • Terms of Use
Powered by GitBook
On this page
  • Overview
  • Key Concepts
  • Google Analytics Events
  • The Fun Part
  • Getting Started
  • Getting to know the Global Widget Events API
  • Sending data to Google Analytics
  • Conclusion

Was this helpful?

  1. Guides
  2. Analytics

Tracking Widget interactions with Google Analytics

PreviousTracking UGC on Adobe AnalyticsNextDirect Uploader

Was this helpful?

Overview

Nosto's UGC provides a Google Analytics plugin that allows you to track common user interactions via Google Event tracking.

The data sent to Google Analytics is pre-set and configuration is limited to choosing which Widgets you want to track and the specific interactions you want to track on them.

In this guide we will use the Nosto's UGC to customise the data that is sent to Google Analytics for the events we choose to track.

Key Concepts

Google Analytics Events

are user interactions with content that can be tracked independently from a web page or screen load.

Data related to these interactions can be sent to Google Analytics.

The Fun Part

Getting Started

In this example we will need to do the following:

  • Use Google Analytics event tracking methods to send some of this data to Google Analytics.

Getting to know the Global Widget Events API

Today we’ll work with two:

  1. tileExpand - triggered when a user clicks a Tile to view it in a lightbox

  2. productActionClick - triggered when a user clicks a “Buy” button on a Tile (Social Commerce feature)

First we’ll look at what data these events makes available, then we’ll configure Google Analytics event tracking to send some of this data to Google Analytics when users trigger these events.

To start, we’ll crack open the Custom Code Editor on our Widget, switch to the Expanded Tile tab and add the following code.

Adding this code in the Expanded Tile JS editor instead of directly on the parent page means Nosto's UGC will load this code for us when Stackla.WidgetManager global variable is available, avoiding the need to check and re-check for this variable before executing our code.

Stackla.WidgetManager.on('tileExpand', function (e, data) {
    // Log all the available data to the console
    console.log(data);
});

With this, we’ll get a dump in the console of all the data associated with the tileExpand event that Nosto's UGC makes available.

This data is contained inside an aptly named data object. Let’s fetch some stuff from there and send it to Google Analytics via event tracking.

Sending data to Google Analytics

Before we look into this further, we'll need a way to establish how this data is being sent to GA. As the ga() calls do not use the current Nosto's UGC Google Analytics plugin Tracking ID or data, we'll need to include this in the Widget or the parent page with the tracking ID:

 (function(i, s, o, g, r, a, m) {
        i.GoogleAnalyticsObject = r;
        i[r] = i[r] || function() {
            (i[r].q = i[r].q || []).push(arguments);
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
            m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m);
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

 ga('create', 'UA-XXXXXX-X', 'auto'); 
 //CHANGE THE X TO the Tracking ID
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject])

The eventCategory, eventAction and eventLabel values correspond with columns in our Google Analytics Event reports and we’ll replace them with data from our data object.

We’ll leave eventValue blank as it is not required. We’ll also omit fieldsObject for now.

Here goes…

Stackla.WidgetManager.on('tileExpand', function (e, data) {
    ga('send', 'event', 'Widget (' + data.widgetId +') Filter (' + data.filterId + ')', 'Tile expand', 'tile_id: ' + data.tileData._id.$id + ', source: ' + data.tileData.source + ', media: ' + data.tileData.media);
});

Here’s a breakdown of the above:

For eventCategory we have included “Widget (Widget ID here), Filter (Filter ID here)”. That way we can report on each Widget/Filter combination on our website.

eventAction describes the user interaction that has taken place - ‘Tile expand’ seems an accurate label.

Our eventLabel is where most of our data will be sent. In this case we’ve included things like the Tile ID, the source (network) and the media type. This will allow us to answer questions like “which media type (image, video, text) attracts the most clicks?”.

When we log in to Google Analytics, hit the Reporting tab and go to Behaviour > Events > Top Events we’ll see something like this:

Let’s track another event…

Stackla.WidgetManager.on('productActionClick', function (e, data) {
    ga('send', 'event', 'Widget (' + data.widgetId +') Filter (' + data.filterId + ')', 'Buy button click', 'tile_id: ' + data.tileData._id.$id + ', source: ' + data.tileData.source + ', media: ' + data.tileData.media + ', sku: ' + data.productTag.ext_product_id);
});

This event will track clicks on a product buy button on a Nosto's UGC Tile (productActionClick).

We’ll send the same data that we did for the tileExpand event but we’ll also append the product sku to the eventLabel. Product sku is stored in the ext_product_id field on a Tile and made available in the data.productTag object for this specific event.

By drilling down on “Buy button click” events in GA, we can filter by product sku to see which Tiles are driving the most traffic to our purchase pages.

Conclusion

Use the to find out what data Nosto's UGC Widgets make available for the user interactions that we choose to track.

Nosto's UGC’s provides a number of events that you can subscribe to in order to track user interactions.

Once this is done we can replace the console log with a Google Analytics Event method which has :

By leveraging the events and data made available by the we can customise the data sent to Google Analytics.

this format
JavaScript API
Events
Overview
Key Concepts
The Fun Part
Getting Started
Getting to know the Global Widget Events API
Sending data to Google Analytics
Conclusion
Back to Top
Back to Top
Back to Top
Back to Top
Back to Top
Back to Top
Global Widget Events API
Global Widget Events API
Global Widget Events API