3

Is it possible to show a small block (using code or a module or something) that shows how many times the page a user is on has been shared using ANY of the available sharing methods?

For example, I'm trying to use the social sharing module AddThis and I'm showing the Facebook, Twitter, and Pinterest, and Email icons (although I also want to use the 'more' icon to show all the others).

And I want a little box to the right of those that just shows how many times the page has been shared. Is this even possible?

4 Answers 4

5

you could use:

Social Share Counter Module

This module is clearly inspired by the share buttons used by Mashable.

This module gives the share counts for only Facebook,Twitter and more which has some excellent features in more elegant manner. If you have a website, then you definitely need this module.

If you still want to use AddThis, then use Social Stats Module

This is a statistics module. It provides data from various social media sites. The data which is saved per node. It includes data from:

Facebook : likes count, shares count, comments count & total count.

Twitter : tweets count.

LinkedIn : share count.

Google Plus : plus one

count, share count & total count Total Share Count : total across all available social networks Note: This module is intended to collect the statistics per node from the networks mentioned above.

It does not actually provide sharing widgets for the social networking sites. They have to added manually, or using other modules. List of the modules recommended to use alongwith Social Stats are:

  • Service links
  • AddThis
1
  • Hm, interesting answer also! But also a huge red flag for the Social Share Counter module: alfa6 version for D7 only (and only a "few" reported installs). If it was for my own site, I'd put that module on my watchlist for a while (to see where it is at in say 3 to 6 months from now). Anyway: +1! Dec 11, 2015 at 8:38
5

The Social Share Statistics is better than other modules listed in other answer.

Social Share Statistics:

This module is developed to track the share statistics of social media clicks. So when a registered drupal user shares any content to social media, this module saves the uid, nid and the share count for FB/twitter/GPlus in the database for the record.

There is a 'Shares' tab on the user profile page where the user can get the list of content shared on different social networks (facebook, twitter).

This module only tracks shares that are made using the share buttons that the module provides. If you share the nodes with some other mechanism (say directly copy paste the link to Facebook, Twitter, etc. or use some other module), those actions / shares do not count.

Please read the readme.txt file for detailed instructions on configuration steps.

Reason Why it is better than other module:

The reason why this module is different from the rest of the modules available on d.org is it tracks which user shared which node. This we didn't find in any other module. For example - Social Stats just shows number of shares per node but which registered user shared which node is not available with Social Stats module and even the way the count is fetched is different in both the modules.

3

Get Rules involved

Have a look at my answer to "How to post the node link in social networking if node is published?", which explains how the Rules module can be used as an engine to post to various social networks, such as Facebook and Twitter.

Let Rules track your social networking services

By using Rules as your "Social Network Dispatcher" (or whatever you'd call it), you can have the Rules module ALSO take care of keeping track of "how many times the page a user is on has been shared using ANY of the available sharing methods". Here are the highlights of what you'd need to get that to work:

  • Add a field (say with machine name field_sharing_counter), to any of your relevant content types for which you want to implement the below logic. That field (initial value = 0) will be used as your "counter" (= "how many times a page is shared").

  • Expand the rules used for posting to social networks, with basically only these enhancements:

    • Add a Rules Condition like "entity has field" (related to your field_sharing_counter field). That way you know it's a page you want to monitor.
    • Add a Rules Action which simply increments the field_sharing_counter field.
  • To make the above Rules expansions AbitMORE modular, I'd recommend to move this logic into a Rules Component (so that the modifications of the relevant rules are limited to just adding 1 rules action (= trigger that Rules component). The extra advantage you have that it's a peace of cake to maintain this extra logic (just adapt the single Rules component to have it apply for all Rules that use it).

Once you have this field_sharing_counter in place (and updated via Rules), it's straight forward to build a Views block with the specs matching your "small block" (it'd get boring to also provide the details for such view here, right?).

The above approach should work for at least Facebook and Twitter (more homework needed to find out how Rules can "talk" to Pinterest, though Googme+ might be tough ..).

Variations:

  • By using a separated field for each social network, you can even make it like X times 'Facebook', Y times 'Twitter', and Z times 'others'.
  • If you'd create like a special "Thank you for sharing on ABC" node (1 for each social network), you could have the Rules module perform a Rules action to redirect to that special node after sharing (and use a destination parameter to return to the page that was shared). And the number of page visits for each of these special nodes would be the "counter" that obsoletes the field_sharing_counter field entirely.
2
  • Never thought of approaching this with rules. Rules never fails to amaze me.
    – No Sssweat
    Dec 16, 2015 at 17:56
  • Merci for the compliment .. To be honest: before this question was asked, I never thought about using Rules like this either. Consider this as a sample of using Drupal.SE as your Ask-Me-Anything trainings partner (I sometimes use these kinds of samples when teaching Drupal). And when I see this kind of question I ask myself "there has to be a way to do it with only 'Rules' (and maybe 'Flag' or some of the other typical Rules-related modules) ... can't be that you'd need custom coding for this" ... Dec 16, 2015 at 18:15
1

All of these are great answers. It turns out the AddThis module includes something you can use right out of the box to do this counting. Just add the 'bubble_style' option to your toolbox when configuring the display for the field in your content types and this automatically counts all the shares using the other services you've loaded for the module.

Not the answer you're looking for? Browse other questions tagged or ask your own question.