Google Analytics integration and how to use it.
Plugin has the option to track via Google Analytics all clicks on social buttons that were made on your site.
By default this option is disabled but if you installed Google Analytics on your site then you can enable it from the plugin settings page.
After you enable every click on the social button will be sent to your Google Analytics property. There you will be able to see all data about images sharing - number of shares, what images were shared and what social buttons were used.
Next step is to properly configure GA property to receive and display Share This Image sharing events.
Note: this chapter is relevant only if you are using Google Tag Manager on your site instead of GA4 tag. Overwise proceed to the next chapter to learn how to set events for GA4.
When Google Analytics integration is enabled and website users share any of your images, the following custom event appears:
Event name: sti_share
Event parameter:
sti_button
- sharing button name
sti_image
- URL of image that was shared
First of all we need to send these events to the GA4 dashboard via the currently active tag manager account.
Steps to set-up custom events tracking:
1. Open your Google Tag Manager account dashboard. Make sure that it is loaded for your needed site.
2. First we need to create variables for our sti_share
event. Open Variables tab and click New button.
Set two new variables with following parameters:
Variable 1
Title: sti_button
Variable Type: Data Layer Variable
Variable Name: eventModel.sti_button
Variable 2
Title: sti_image
Variable Type: Data Layer Variable
Variable Name: eventModel.sti_image
3. Now we need to create an event trigger. Open Triggers tab and click New button.
Set following trigger:
Title: sti_share
Trigger Type: Custom Event
Event Name: sti_share
4. Final thing that we need to do is to create a tag that will send sti_share
custom event with variables to our GA4 property.
So open Tag and and create the following new tag:
Title: STI event
Tag Type: Google Analytics: GA4 Event
Measurement ID: {your Measurement ID}
- can be found inside GA4 dashboard -> Admin -> Data collection and modification -> Data streams -> {your stream}
Event Name: Choose Event variable
Event Parameters:
Parameter 1:
Name: sti_image
Value: sti_image
variable from the list
Parameter 2:
Name: sti_button
Value: sti_button
variable from the list
Triggering: Choose sti_share
trigger.
5. We are done. Now just review and publish all changes for the current container by pressing Submit button at the top right corner for your GTM account.
We are done with setting-up custom events for Google Tag Manager. Now we need to set GA4 account events to properly track all these data. We will cover how to do that in the next chapter.
When you enable Google Analytics integration from the plugin settings page following custom events with parameters are sent with each image share:
Event name: sti_share
Event parameter:
sti_button
- sharing button name
sti_image
- URL of image that was shared
To view this event and its parameters inside GA4 dashboard first we need to properly configure this custom event tracking.
Steps to set-up sti_share custom event and its parameters:
1. Open your GA4 property admin page and then go to Events page.
2. Click Create Evens button and then create a new event with the following parameters:
event_name -> equals -> sti_share
Also make sure that checkbox Copy parameters from the source event
are checked.
After you are finished - click Save button.
3. Now we need to create two custom definitions to track values from event parameters sti_button
and sti_image
.
First open Custom Definitions page.
4. Inside this page click Create custom dimension button.
Create a new dimension with the name sti_button
, scope - Event
and event parameter - sti_button
. Then save all changes.
Also create a second dimension with the name sti_image
, scope - Event
and event parameter - sti_image
.
5. We are done! Custom events and dimensions are properly set. Now we need to wait for 24 hours till Google Analytics accumulates new data.
Now we need to display these sharing data inside the GA4 dashboard. Learn how to do that in the next section.
So we properly set-up sti_share
custom event tracking as well as tracking of its custom parameters sti_button
and sti_image
.
Now it is time to view this data inside the GA4 dashboard.
This can be done via 2 ways: inside default Events report or by creating custom events exploration.
All custom events tracking can be found inside Engagement -> Events page.
Open this page, find the list of all available events and click on sti_share
event to view all data related only to this particular event.
Inside sti_share
event page you can find event related data like total number of events, total number of users associated with this event, users country, etc. You can also select the time period for which you want to display the required information.
At the bottom of this page you can find information about our custom dimensions - sti_button
and sti_image
. Here you can view what images and to what social networks were shared during a selected period of time.
So such a default Events page contains a large amount of useful information. In most cases, this information is quite sufficient. But if you need to build more advanced reports with additional details, custom charts, etc. then take a look on custom explorations.
GA4 provides a feature to build fully custom reposts and represent any data inside them.
In this section we will cover how to create such a custom report for sti_share
event and display sti_button
, sti_image
and total events number
values inside it.
1. Go to the GA4 Explore page and create a new blank report.
2. Set the following variables for that report:
Dimensions - choose previously created sti_button
and sti_image
dimension.
Metrics - Choose Event count
value.
Segments - create a segment that includes only sti_share
events.
Then on the right tab ( settings ) for Rows option choose sti_button
and sti_image
values. And for the Values option choose Event count
.
If everything is set up correctly - you will see a table with data about every image sharing event on your site.
Additionally you can track your sharing data inside any other analytics tools ( or send any other additional events to GA ). This can be done with the help of stiAnalytics
js event that is triggered after any image sharing event.
Note: This event is triggered even if Google Analytics option is turned off.
Example - let's send an additional event my_custom_sti_event
with parameters about sharing button and image to our GA4 instance.
1. Open the functions.php file in your child theme or use any plugin for adding custom code snippets.
2. Add the following php code snippet:
add_action( 'wp_footer', function () { ?> <script> jQuery(document).on('stiAnalytics', function (e) { window.dataLayer.push({ 'event' : 'my_custom_sti_event', 'custom_param_1': e.detail.button, 'custom_param_2': e.detail.image }); }); </script> <?php }, 100 );
this code will send my_custom_sti_event
event with custom parameters custom_param_1
and custom_param_2
to your GA4 property.
Customize this code any way that you want. For example - use it to send data about users shares to other analytics tools.
Custom data available with this code:
e.detail.button
- current sharing button name
e.detail.image
- URL of shared image
To view sharing events go to your GA account and open Behavior -> Events tab.
Plugin events will have the following parameters:
Event Category = STI click
Event Action = {social button name}
Event Label = {shared image URL}
Don't forget that Google Analytics has some delay between action and its display on GA dashboard.