Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Google+ API: Sharing An Interactive Post

Google+ API: Sharing An Interactive Post

2

The Google+ API allows you to create interactive posts you can share from your website, which contain a call-to-action button with an image and details from the link you want to share. The API lets you pre-fill the text the user can use to share your link (something which Facebook as removed from their API), and gives you options to add in deep-links for mobile apps too.

Google+ Interactive Share

The code below shows how easy it is to create a interactive share button, with a few lines of JavaScript and some HTML to render the button.

You can customise the following attributes:

  • data-contenturl – the URL you want to share
  • data-contentdeeplinkid – the deep-link URL
  • data-clientid – Client ID from Google APIs Console
  • data-prefilltext – The text you want to pre-fill for the user
  • data-calltoactionlabel – label for your call-to-action button, see the full list here.
  • data-calltoactionurl – URL for the call-to-action button. The content URL and the call-to-action URL must match for the post to work.
  • data-calltoactiondeeplinkid – the deep-link URL for the call-to-action

It is currently not possible to track sharing of the interactive post, but it is possible using the standard Share button.

Google APIs, Google+, JavaScript

2 comments on “Google+ API: Sharing An Interactive Post”

  1. Ivan says:
    September 25, 2015 at 9:40 PM

    Hi,

    Is it possible to receive a callback after successful share?
    Thank you,
    Ivan.

    Reply
    • Niraj Shah says:
      September 30, 2015 at 9:52 AM

      No. Google+ does not send callback on share, only when pressing the button. So you cannot correctly determine if the user actually shared a post.

      Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

PSN Profile

Tags

Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache API Application Backup Bug Command Line Cordova Example Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Geolocation Google Nexus 5 Google Nexus One Hacking HTML5 Image Manipulation iOS iPhone JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2022 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy