Social media sharing using sharemessage

Sharemessage is a simple module that provides an interface for the configuration of sharing widgets to a Drupal site. It is using addthis share widgets and provides an exportable entity which contains the data you want to share on a specific page.

Basic setup

In a first step i will describe the two possible ways for displaying a ShareMessage on a site. In order to do so you have to create a ShareMessage first.

  1. The first approach is to use share messages as a block. Just edit your ShareMessage and check the option "Provide a block" and save the ShareMessage. Once this is done, a block with the corresponding sharemessage will show up in the blocks configuration. The advantage of this approach is that you can control where the sharemessageis displayed using the usual block configuration with wildcards, roles etc.
  2. The second way is more content related and requires the entityreference module. Install and enable the entityreference module and add an entityreference field on the entity on which you want to display ShareMessage. In the field configuration use the target type "ShareMessage" and mode "Simple". Afterwards go to manage display and change the format of your entityreference field to "Rendered entity" and make sure you use view mode "Full content" in the format settings. The main advantage of this method is that you can control where exactly inside your entity/node the ShareMessage will be displayed. Also the ShareMessage will automatically be displayed on every node/entity of a bundle.

Another thing i will explain here is a use case that we encountered in at least two projects already.

Sharing participation / activity

For example let's say your website features a shop with a thank you page that is displayed upon checkout completion. Now let's further assume you want to allow your customers to share what they just bought with a message like "Wow i just bought this super awesome product and it is really super awesome.". For this reason you place a share message on the thank you page. The ShareMessage URL will probably point to the page of that super awesome product, which in some cases may already have another associated ShareMessage.

So once a user buys the product and shares it on facebook for example, the posted share message will be based on the og tags of the ShareMessage that is dispayed on the product node itself and facebook will show a description like "super awesome product ...". But what we actually want facebook to display is "Wow i just bought this super awesome product and it is really super awesome.". So there must be a way to override the existing og tags on that page with those of our thank you page ShareMessage.

ShareMessage now has a new feature that will exactly do that and it's as simple as checking a checkbox. So let's say you have the ShareMessage for the product page and another one for the thank you page whose og:url tags both point to the product page. So all you have to do now is to edit the thank you page ShareMessage and check the option "Enforce the usage of this share message on the page it points to".

What happens is that once the option is set and the ShareMessage gets rendered, a query string like ?smid=3 is appended to the actual value of the og:url tag. When facebook eventually loads that URL, ShareMessage will automatically load the ShareMessage with id 3 and override the og tags of the original ShareMessage on that page.

Conclusion

Sharing this way is easy and you can do the most advanced personalized sharing strategies with no code to improve your social media channel conversions.

Simpy said, that's awesome.