Track social media interactions with the web trackers
Social interaction tracking is provided as part of the Site tracking plugin. This plugin also provides events for site search and timings.
Social media interaction events must be manually tracked.
Install plugin
- JavaScript (tag)
- Browser (npm)
| Tracker Distribution | Included |
|---|---|
sp.js | ✅ |
sp.lite.js | ❌ |
Download:
| Download from GitHub Releases (Recommended) | Github Releases (plugins.umd.zip) |
| Available on jsDelivr | jsDelivr |
| Available on unpkg | unpkg |
Note: The links to the CDNs above are pinned to a specific version at the time of writing. Check the plugin's GitHub releases for newer versions, and update the pinned version when you upgrade.
window.snowplow('addPlugin',
"https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-site-tracking@4.10.2/dist/index.umd.min.js",
["snowplowSiteTracking", "SiteTrackingPlugin"]
);
npm install @snowplow/browser-plugin-site-trackingyarn add @snowplow/browser-plugin-site-trackingpnpm add @snowplow/browser-plugin-site-tracking
import { newTracker, trackPageView } from '@snowplow/browser-tracker';
import { SiteTrackingPlugin, trackSiteSearch } from '@snowplow/browser-plugin-site-tracking';
newTracker('sp1', '{{collector_url}}', {
appId: 'my-app-id',
plugins: [ SiteTrackingPlugin() ],
});
Event
Social tracking is used to track the way users interact with Facebook, Twitter and Google + widgets, e.g. to capture "like this" or "tweet this" events.
The trackSocialInteraction method takes three parameters:
| Parameter | Description | Required? | Example value |
|---|---|---|---|
action | Social action performed | Yes | 'like', 'retweet' |
network | Social network | Yes | 'facebook', 'twitter' |
target | Object social action is performed on e.g. page ID, product ID | No | '19.99' |
The method is executed in as:
- JavaScript (tag)
- Browser (npm)
snowplow('trackSocialInteraction', {
action: string,
network: string,
target: string
});
For example:
snowplow('trackSocialInteraction', {
action: 'like',
network: 'facebook',
target: 'pbz00123'
});
import { trackSocialInteraction } from '@snowplow/browser-plugin-site-tracking';
trackSocialInteraction({
action: string,
network: string,
target: string
});
For example:
import { trackSocialInteraction } from '@snowplow/browser-plugin-site-tracking';
trackSocialInteraction({
action: 'like',
network: 'facebook',
target: 'pbz00123'
});