Add a Google+ "share" button to your storefront
Modular Merchant's shopping cart software makes it quick and simple to add a Google+ share button to any page of your online store. This article will provide instructions on how to create and customize a share button in your cart.
First off, what will the share button look like in the storefront? It can be customized in a number of ways (which is described in more detail below) but, by default, the share button will look something like this:
Displaying the Google+ Share button in your storefront
As you know, each page of your public storefront — where your customers come to shop and check out — has a corresponding HTML template that controls its design.
Each storefront page has its own template: the store's home page has one, the search page has one, the checkout page has one, etc.
The share button can be added to any storefront page by adding the following QuickCode Tag to the desired location on that page's template: {GOOGLE-PLUS-SHARE}.
The button will be inserted into a page wherever that QuickCode Tag is located within that page's HTML template.
the universe: no assembly required
Most of the Template Packages created by Modular Merchant will already include the { GOOGLE-PLUS-SHARE} QuickCode Tag in various templates. In that case, no further customization of templates is necessary.
Also, if you're using the Universal Template system (which allows you to use just one single template to control the design of every page of your storefront) then this QuickCode Tag is already in place on various storefront pages and is ready to use.
It's not necessary to edit any templates to add this feature if you're using a Universal set of templates.
In summary, a share button can be added to any page in your online store simply by:
-
adding the {GOOGLE-PLUS-SHARE} QuickCode Tag to the desired location on those pages.
And this single step may not even be necessary, if using one of the pre-made templates provided by Modular Merchant.
Next, we'll review some of the advanced options that are available for customizing the look and behavior of your share button.
Customizing the {GOOGLE-PLUS-SHARE} QuickCode Tag
As mentioned above, the {GOOGLE-PLUS-SHARE} QuickCode Tag can be used as-is to display a share button in your storefront. However, it can also accept several parameters, which can be used to customize its appearance and behavior. The available parameters include:
google+ share button quickcode tag parameters
href
The URL to share. If you set this attribute by using gapi.plus.render, you should should not escape the URL.
Possible values: Any URL
Default: Current page's URL
annotation
The annotation to display next to the button.
Possible values: inline, bubble, vertical-bubble, none
Default: bubble
width
The maximum width to allocate to the entire share plugin. See Button Sizes for more information.
Possible values: Any number
Default: —
height
The height to assign the button. This may be 15, 20, 24 or 60. See Button Sizes for more information.
Possible values: Any number
Default: 20
align
Sets the alignment of the button assets within its frame.
Possible values: left, right
Default: left
expandTo
The preferred positions in which to display hover and confirmation bubbles, relative to the button. Set this parameter when your page contains certain elements, such as Flash objects, that might interfere with rendering the bubbles.
If omitted, the rendering logic will guess the best position, usually defaulting to below the button (bottom).
Possible values: comma-separated list of top, right, bottom, left
Default: empty list
onstartinteraction
If specified, this function is called when an interaction bubble appears (such as when the user hovers over the button or starts the sharing flow). This function must be in the global namespace and may accept a single parameter, which will be a JSON object.
Possible values: function(jsonParam)
Default: —
onendinteraction
If specified, this function is called when the interaction bubble disappears. You can use this callback function to modify your page, such as resuming a video, when the bubble closes. This function accepts a single parameter, which is identical in structure to the parameter passed to onstartinteraction.
Possible values: function(jsonParam)
Default: —
reference
Passing parameters in the QuickCode Tag
Parameters can be passed within the QuickCode Tag in two ways.
Name/Value Pairs
The preferred method is to use name/value pairs. In this approach, both the name of the parameter and its value are included in the QuickCode Tag. This allows you to set custom values for any number of the available parameters, in any order.
example
For example, to set custom values for just the "width" and "annotation" options, the QuickCode Tag would look something like this when using name/value pairs:
{GOOGLE-PLUS-SHARE:width=300:annotation=bubble}
Note that when using name/value pairs, the parameters may be included in any order, and unused parameters may be excluded.
Values Only
Optionally, just the values of the parameters may be included. This can make the QuickCode Tag shorter in some cases, however, when including only the values of each parameter they must be kept in order.
example
For example, to set custom values for just the "width" and "annotation" options, the QuickCode Tag would look something like this when using just values:
{GOOGLE-PLUS-SHARE:http://www.example.com/page.html:bubble:300}
Note that when using only the values, all parameters from the first one through the last one you use must be present and in the correct order.
don't leave space for spaces
Remember, a QuickCode Tag, including any included parameters, can not contain any spaces.
Correct: {GOOGLE-PLUS-SHARE:width=300:annotation=bubble}
Incorrect: {GOOGLE-PLUS-SHARE : width=300: annotation=bubble}
Incorrect: {GOOGLE-PLUS-SHARE: width = 300 : annotation = bubble}
Using the examples above, it is possible to add a Google+ share button to any page of your storefront. The display of the button can also be customized by including additional parameters in the {GOOGLE-PLUS-SHARE} QuickCode Tag. |