Legacy Google+ APIs have been shut down as of March 7, 2019. Changes to the shutdown plan have been made recently which may mitigate its effect on some developers. Learn more.

Google+ integrations for web and mobile apps have also stopped functioning as of March 7, 2019. Learn more.

Manage app activities in Google

After the user signs in using the Google+ Sign-In button, you can write app activities to Google on behalf of your user with the moments methods. App activities reflect a variety of user actions including check-ins, reviews, commenting on articles, and more. Users control the visibility of their app activities on Google using circles. Your app can use the type of activity that best reflects your content or the user's action.

Before you begin

App activities require a target URL whose page contains schema.org microdata to semantically describe the content to help Google better understand the content and the interaction. Each of the app activity types includes examples of target pages.

You must create a Google API Console project and add the Google+ Sign-In button to your page.

Write an app activity to Google

When a user performs an action within your app, your app can write an app activity to the authenticated user's Google account using the moments.insert method. The target of your app activity might be a comment, a document, a song, or something else that the user might interact with in your app.

Writing an app activity using the sign-in button

When a user signs in with the Google+ Sign-In button, you get an OAuth token for making API requests on their behalf.

When authenticating for moments.insert, you must include the data-requestvisibleactions parameter to specify which types of App Activities your application will write.

After a user signs in with the Google+ Sign-In button, you can use the Google Javascript Client to write moments.

The target of your app activity must have a URL associated with it, and you will provide that URL as part of the object that represents the moment. When the activity is written to Google, a snippet is generated from that target URL. The target URL should have a schema.org type associated with the page that matches the moment type that you specify.

  1. Construct an object representing the activity you want to write, for example, review activity.

    var moment = {
         'type': 'http://schema.org/ReviewAction',
         'target': {
           'url': 'https://developers.google.com/+/web/snippet/examples/movie'
         'result': {
           'type': 'http://schema.org/Movie',
           'name': 'Night of the Living Dead',
           'url': 'https://developers.google.com/+/web/snippet/examples/movie',
           'text': 'It is amazingly effective at whatever it is that it is supposed to do.',
           'reviewRating': {
             'type': 'http://schema.org/Rating',
             'ratingValue': '100',
             'bestRating': '100',
             'worstRating': '0'
  2. Use gapi.client.request to write a moment to the current user's account. This must be done after the user is connected and a valid access token is set on gapi.client.

    var request = gapi.client.request({
        'path': 'plus/v1/people/me/moments/vault',
        'method': 'POST',
        'body': JSON.stringify(moment)
    request.execute(function(result) {
  3. Add schema.org microdata to your target URL and, if applicable, to your result URL. See the app activity types for additional information and requirements listed by type of activity.

Google can obtain an image by crawling your target URL for moments that do not specify an image field. All content associated with your target URL that Google obtains and uses in connection with a moment is considered content that you submit to Google under Section 5 of the Google APIs Terms of Service.

Writing an app activity using the Google APIs client libraries

If you do not use the Google+ Sign-In button and instead are using OAuth directly, you must specify the request_visible_actions parameter to specify which types of app activities that your application will write. The following code snippets demonstrate how to specify that parameter when you are using the Google API client libraries.


Uses the Java client library

// In Java, you can append 'request_visible_actions' to the Authorization
// Server Url passed to the constructor of AuthorizationCodeFlow.
// The app activity types requested in the snippet are AddAction and
// ReviewAction.

GenericUrl authUrl = new GenericUrl(

// Append 'request_visible_actions' to the Authorization Server URL.
    Joiner.on(' ').join(
        new String[] { "http://schema.org/AddAction",
            "http://schema.org/ReviewAction" }));
authorizationCodeFlow = new AuthorizationCodeFlow.Builder(
    BearerToken.authorizationHeaderAccessMethod(), TRANSPORT,
    JSON_FACTORY, new GenericUrl(GoogleOAuthConstants.TOKEN_SERVER_URL),
    new ClientParametersAuthentication(ConfigHelper.CLIENT_ID,
        ConfigHelper.CLIENT_SECRET), ConfigHelper.CLIENT_ID,
    authUrl.toString()).setCredentialStore(new MemoryCredentialStore())


Uses the JavaScript client library

// In Javascript, you can pass 'request_visible_actions' to gapi.auth.authorize.
// The app activity types requested in the snippet are AddAction and
// ReviewAction.

var actions = ['http://schema.org/AddAction',
    'http://schema.org/ReviewAction'].join(' ');
  client_id: clientId,
  scope: scopes,
  request_visible_actions: actions,
  immediate: true},


Uses the PHP client library

# In PHP, you can append 'request_visible_action' to the URL generated
# by 'createAuthUrl'.
# The app activity types requested in the snippet are AddAction and
# ReviewAction.

$client = new Google_Client();
$plus = new Google_PlusService($client);

$authUrl = $client->createAuthUrl();
$visibleActions = array(

$authUrl .= '&request_visible_actions=' .
    urlencode(implode(' ', $visibleActions));
print '<a href="' . $authUrl . '">Sign in with Google</a>';


Uses the Python client library

# In Python, you can pass the 'request_visible_actions' parameter to the
# constructor of OAuth2WebServerFlow.
# The app activity types requested in the snippet are AddAction and
# ReviewAction.

visible_actions = (' ').join([
flow = OAuth2WebServerFlow(


Uses the Ruby client library

# In Ruby, you can append 'request_visible_actions' to the authorization URI
# generated by Signet::OAuth2::Client.
# The app activity types requested in the snippet are AddAction and
# ReviewAction.
@authorization = Signet::OAuth2::Client.new(
  :authorization_uri => ‘https://accounts.google.com/o/oauth2/auth’,
  :token_credential_uri => ‘https://accounts.google.com/o/oauth2/token’,
  :client_id => ‘YOUR_CLIENT_ID’,
  :client_secret =>’YOUR_CLIENT_SECRET’,
  :redirect_uri =>’YOUR_REDIRECT_URI’,
  :scope => ‘plus.login’
@authUrl = @authorization.authorization_uri.to_s;
@visibleActions = [
  'http://schema.org/ReviewAction'].join(' ');
@authUrl += '&request_visible_actions=' + URI.encode(@visibleActions);

You can find snippets of code documenting how to write app activites for each language in the moments.insert method documentation.

Next steps

Send feedback about...

Google+ Platform
Google+ Platform