Twitter Data Collection Plugin

Twitter Plugin for Analytics

The purpose of this plugin is to track visitor intents on Twitter for Websites Widgets and intent links.

How it works

Twitter for Websites Javascript (TWWJS) provides a JS interface for easily binding and listening to Twitter events, which plugin assigns listeners to when loading. The interface is available globally via window.twttr.events.

More information: JavaScript Interfaces for Twitter for Websites @ Twitter Developers

The plugin loading workflow:

  • Availability of window.twttr is checked and if it is not yet available then polling begins with default polling frequency of300ms. This value is configurable via Webtrends Support.
  • The polling has a default timeout value of 4000ms (same as default tracking pipeline timeout). This value is configurable via Webtrends Support.
  • Once the plugin has loaded and window.twttr object appears, polling will complete and the plugin creates listeners for Twitter events.
  • The plugin then notifies parent Analytics module that it is ready.

Tracked Twitter Events

Below is a list of native Twitter event types that can be bound and listened for via plugin interface. The plugin binds only to those that are triggered on visitor actions (i.e. intents). Other events like loaded and rendered often occur before plugin has loaded, and are therefore are ignored.

Please note: All of the Twitter events signify only the visitor’s intent to do something (i.e. follow), they do not mean that visitor followed through to complete the action.

Basic Event Bound Purpose
rendered N Triggered on each Web Widget render
loaded N Emitted when plugin finished rendering widgets and loading
click Y This one is always triggered first and together with any of the events below (i.e. tweet). For example, when a visitor clicks on any of Twitter Widgets or intended actions, there is a clickevent followed by tweet. So in the end there are two events on each visitor action on a Twitter widget. This event is used only for intended actions that do not trigger any of the follow-up below events (i.e. display user).
tweet Y Triggered on tweet, reply to, and related events
follow Y When visitor clicks to follow another user
retweet Y When visitor clicks to retweet a tweet
like Y When a visitor click to like a tweet

More information: Scripting: Events | Twitter Developers

Plugin configuration

The plugin has a few configuration settings that can be set by Webtrends Support:

Param name Default value Purpose
enable true Enable plugin functionality. Meant more as a switch to disable plugin if needed.
blockCollect false This value has to be set to true to allow time for plugin polling
timeout 4000 The value from the tracking pipeline timeout. Time given for plugin to load and add mutations in time for pageview.
iPollFreq 300 The frequency at which to poll for Twitter events
inTest false Expose internal methods for testing via window.WT.plugins.TW._test_

For example:

...
"wt-plugins" : {
    "tw" : {
        "enable": true,
        "timeout": 4000,
        "iPollFreq": 300,
        "blockCollect" : true,
        "timeout" : 4000,
        "inTest" : false
    }
}
...

Tracked Analytics parameters

Most of the parameters are tracked either on pageview, social action or both.

Param name Tracked on Example val Conditions Purpose
WT.dl Always 111 The type of event. For pageviews it is set to “0”. A social conversion always has the value “111”.
WT.soc_action Social action Twitter:Like Social action name
WT.soc_content Social action URL/username/tweetID/etc. Social action-specific content (depending on action)
WT.tw_js Always 1 1 = Twitter Widgets JS is loaded (i.e. window.twttr is available), 0 = no TW JS was detected when plugin was loading
WT.tw_plver Always 1.0.0 Twitter plugin version
WT.tw_timeout Always 1 1 = timed out while waiting for Twitter Widgets JS to load
WT.tw_intent Social action tweetMention Heuristically determined type of intent (plugin-specific)
WT.tw_hashtag Social action TwitterStories Tweets with #hashTag Contains the hashtag pre-set for a tweet
WT.tw_region Social action tweetcount, follow,screen_name Extended detail indicating where in a Twitter widget the event originated.
WT.tw_tweetid Social action 463440424141459456 specific events ID of a tweet post on which action was taken
WT.tw_srctweetid Social action 463440424141459456 specific events ID of a tweet post which was retweeted. Only when retweeting via Web Widget (not intents)
WT.tw_usrscrname Social action Interior specific events Screen name of the user that visitor started following (not our visitor name!)
WT.tw_usrid Social action 3308337 specific events ID of the Twitter user that visitor intends to view profile of
WT.tw_wdgid Social action 698123635282804738 specific events ID of an embedded Twitter widget on which the action occured

A10 vs iTag: soc_action & soc_content map

Below table compares the differences of WT.soc_action and WT.soc_content between Twitter plugin by Developer Community (for A10) and this new version of the plugin for the Infinity Tag. Notably, the new version of the plugin improves detection of the intended user action to cover more scenarios around Twitter Widgets and intents.

Twitter Widget type soc_action (A10) soc_content (A10) soc_action (ITag) soc_content (ITag)
Button: Tweet Twitter: Tweet Article URL Twitter: TweetArticle URL
Button: Hashtag Twitter: Tweet Hashtag URL Twitter: Tweet Hashtag URL
Button: Mention Twitter: Tweet To username Twitter: Tweet To username
Button: Follow Twitter: Follow username Twitter: Follow username
Intent: like Twitter: Tweet Article URL Twitter: Like tweet ID
Intent: tweet Twitter: Tweet Article URL Twitter: Tweet URL
Intent: reply (specific tweet) Twitter: Tweet Article URL Twitter: Reply To tweet ID
Intent: retweet (specific tweet) Twitter: Retweet tweet ID Twitter: Retweet tweet ID
Intent: display user not tracked not tracked Twitter: Display User username
Intent: follow user Twitter: Follow intent/follow?screen_name=username Twitter: Follow username

Browser support

Twitter for Websites has dropped support for IE7 and IE8 in January 2015, hence the plugin does not support these browsers either. As a result the plugin will simply timeout due to Twitter SDK dependency objects (i.e. window.twttr.events) never becoming available in the older browsers. More info: Update on Twitter for Websites IE7 and IE8 browser support @ twittercommunity

QA & Test Accounts

An example QA page with all the Twitter Web Widget and intent types is set up on Optlab: http://web-dev.optlab.webtrends.corp/kriauciukasr/ENG-3489-ITag-TwitterPlugin/

There are two accounts created on Twitter.com for testing and QA purposes. The login credentials are located at Thycotic Secret Server -> Engineering -> Engineering Enigma directory.

Username Email Password
WTAnalyticsT1 wtatest1@sharklasers.com Get at Twitter QA Account – 1
WTAnalyticsT2 wtatest2@sharklasers.com Get at Twitter QA Account – 2

References & related