How to Integrate OpenShare with Google Analytics and Tag Manager

Author Avatar
Written by Adam Chambers,
• 5 min read
1400GAOpenshare.png

OpenShare is an easy-to-use social plug-in for content websites that allows site publishers to quickly and easily deploy social media action buttons on their sites in any style or configuration that they wish.  These buttons can be used to share content, follow a social media account, send a text message, subscribe to a YouTube video, or a host of other actions across a wide variety of social platforms.  The code for OpenShare is open source, so it is expandable and configurable to anyone with some Javascript ability.

OpenShare was created by a team of developers at Digital Surgeons as a means to speed social media action button deployment and lend design flexibility to how we enable social actions on our digital experiences.  

Similar “sharing” tools currently exist, but there are serious questions about the ways that they use their data to track visitors across their users’ sites.  Using these third-party tools can expose your users to being tracked by their third-parties across sites where these plugins are enabled, as well as allow the “sharing button” companies to pool your users into audiences for ad targeting.  This is why many of these so-called “sharing” platforms are commonly blocked by ad-blocking tools.  However, site owners might need an easy way to integrate their own tracking protocols into their social sharing buttons – one aspect of these third-party tools is some additional analytics into how your users are sharing your content.

I’m pleased to reveal that the latest release of OpenShare contains something close to my heart: fully-realized Google Analytics and Google Tag Manager integrations.  This speeds deployment of your Google Analytics tracking to your social buttons and, with a full Tag Manager implementation, allows you to pass even deeper sharing information to Google Analytics or to fire other types of marketing or analytics tags through Google Tag Manager dataLayer events.  

I pushed to add these integrations into OpenShare as a means to help my team with our analytics implementations.  Our primary clickstream analytics tool is Google Analytics controlled by Google Tag Manager.  Rather than needing to map our OpenShare click interactions with Tag Manager triggers, OpenShare now fires a dataLayer event for each social interaction click.  This saves us a great deal of time in implementation and allows us to pass more robust data to Google Analytics from interactions with our digital experiences.  It also allows other OpenShare users to easily integrate OpenShare tracking with Google Analytics and permits more advanced tracking and tag firing with Google Tag Manager.

The Three Integrations: Google Analytics Events and Social Actions and Google Tag Manager DataLayer Events

OpenShare’s analytics integrations can automatically fire one or more of the following: Google Analytics Events, Google Analytics Social Interactions, and Google Tag Manager DataLayer Events.  Each of these can be useful to speed analytics deployment on your sites using OpenShare.  

This tracking can be deployed within the loading of the OpenShare script by passing a data attribute to the script call named “data-open-share-analytics”.  The value of the attribute determines the integration(s) loaded.  

 

Here are the values for each integration:

Google Analytics Event:  event

Google Analytics Social Interaction: social

Google Tag Manager dataLayer Event: tagManager

 

For example, if I wanted to fire both a Google Analytics Event as well as a Google Analytics Social Interaction on each OpenShare click, I would load the OpenShare library like this:

Google Analytics Direct Integration

OpenShare’s Google Analytics integration is simple.  On a share button click, OpenShare checks to see if a function named ‘ga’ is defined (the default for the Google Analytics “tracker”) and fires an event to Google Analytics.

 

In the case of Google Analytics events, the following values are passed along with the click:

eventCategory: OpenShare Click

eventAction: the name of the social network (and the action if necessary)

eventLabel: the url of the shared resource or identifying information for non-sharing actions

 

In the case of Google Analytics Social Interactions, the following values are passed along with the click:

socialNetwork: the name of the social network

socialAction: the name of the social action taken

socialTarget: the resource being shared, the account being followed, etc.

Google Tag Manager Integration

OpenShare’s Google Tag Manager integration is also simple.  On a share button click, OpenShare checks to see if Google Tag Manager is loaded in the browser and fires a dataLayer message to Google Tag Manager.  

The dataLayer message contains an event called “OpenShare Share”, which permits you to create a trigger based on this event.  The dataLayer message also contains information related to the share itself: the resource shared, the type of social interaction, the social network, and in some cases extended information such as the current number of shares in that network.

In summary, our hope with this extended functionality is that site owners can embed social sharing buttons into their sites with ease and without fear of compromising their users’ privacy.

Frustrated that Twitter removed share counts? Us too. Contact us to learn more about OpenShare’s solution and how its customizable API wrappers can level up your social media game. Join the #openshare movement!