Creating and publishing promotional web gadgets is a great way to spread the word about the products or services you sell and increase traffic to your website.
Think about a web gadget as a form of social media. Your customers and potential customers can add the gadget to their iGoogle home page, use it on many social networking sites like Orkut and MySpace, or share it with friends online.
In this “eCommerce Know-How,” I show you how to develop a simple “Weekly Feature” gadget based on the gadgets.* application program interface (API) that Google uses.
“Weekly Feature” Gadget
We’ll be using both XML and HTML to create our “Weekly Feature” gadget. But don’t worry. You won’t need to be a web developer or coding guru. In fact, if you have a basic understanding of HTML, you’ll be just fine.
<code> <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs/> <Content type="html"> <![CDATA[Hello World.]]> </Content> </Module> </code>
Start with some very basic XML. The first line of our code declares that our gadget will be written in XML version 1.0. The next line introduces the <Module>
element that will serve as the wrapper or framework for our gadget (in fact, gadgets are sometimes called modules because of this element tag). The last line of code closes the <Module>
element ( notice the “/” in front of the word “Module”). These three lines are essential.
Module Preferences
The <ModulePrefs>
tag specifies gadget characteristics—height in pixels for example—or describes facts about the gadget like the title or the author’s information. To keep things simple, we’ll add four attributes to our <ModulePrefs>
tag. But there are several other attributes that you should add if you want Google to incorporate your gadget in to its gadget directory. For now, take a look at the code with just four attributes.
<code><ModulePrefs title=" Weekly Feature" height="300" scaling="false" author="Armando Emanuel Roggio, Sr." /> </code>
These attributes should be pretty intuitive. In the final code, I will include all of <ModulePrefs>
attributes you’ll need before submitting the gadget to Google’s directory. These additional attributes include:
- description. This attribute will let people know what your gadget does.
- author_email. So that customers or Google can contact you.
- author_location. Describes where your store is located.
- screenshot. Is a link to a screenshot of the your gadget. The image should be in the .png format and exactly 280 pixels wide. Google will use it as a preview.
- thumbnail. Provides a 120×60 pixel .png image representing your gadget.
- title_url. Links your gadget title to a landing page or your home page.
Gadget Content
The <Content>
element has an attribute called “type” that tells the parser (a kind of program that recognizes mark-up languages) what to expect, and includes a sub-element: <![CDATA[Hello World.]]>
.
<code><Content type="html"> <![CDATA[Hello World.]]> </Content> </code>
CDATA stands for character data, and in XML, it is used to tell a parser that the enclosed information is not part of the mark-up, but rather should be interpreted as is. In a gadget, the CDATA tag holds the HTML or other content information. Let’s replace, “Hello World” with some basic HTML that will call in a product photograph and a link back to your store.
<code> <Content type="html"> <![CDATA[ <div> <a target="_blank"href="http://www.yourstore.com/some-product.html"> <img border="0" alt="Photo" src="http://www.yourstore.com/some-product-image.png" title="Product Information"></a> </div> <div> <a target="_blank" href="http://www.yourstore.com/some-product.html ">Product Name and Price</a> </div> ]]> </Content> </code>
You might recognize these HTML tags. The <a>
is used to create a link. The <img>
calls in an image from your website. For your gadget just replace the two instances of “http://www.yourstore.com/some-product.html” with the URL to the landing page you want to target, and substitute ” http://www.yourstore.com/some-product-image.png” with your product photo’s web address.
Add a Bit of Style
You can spice up your gadget by adding style to the HTML. As an example, let’s put a light gray background behind the link and center both the product photograph and the link.
<code> <Content type="html"> <![CDATA[ <div style="text-align:center; " > <a target="_blank" href="http://www.yourstore.com/some-product.html"> <img border="0" alt="Photo" src="http://www.yourstore.com/some-product-image.png" title="Product Information"></a> </div> <div style="text-align:center; background-color:#cccccc;"> <a target="_blank" href=" http://www.yourstore.com/some-product.html "> Product Name and Price</a> </div> ]]> </Content> </code>
The Finished Gadget Code
Now your gadget is complete. I have added in the extra <ModulePrefs>
attributes you’ll need if you plan to submit the gadget to Google’s directory. And now, your code should look something like the following:
<code> <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title=" Weekly Feature" title_url="YOUR STORE URL" height="300" scaling="false" author="YOUR NAME." author_email="AN EMAIL ADDRESS" author_location="YOUR LOCATION" description="DESCRIBE THE GADGET NOT THE PRODUCT" screenshot="SCREENSHOT URL" thumbnail="THUMBNAIL URL"/> <Content type="html"> <![CDATA[ <div style="text-align:center; " > <a target="_blank" href="YOUR URL"> <img border="0" alt="Photo" src="YOUR IMAGE URL" title="Product Information"></a> </div> <div style="text-align:center; background-color:#cccccc;"> <a target="_blank" YOUR URL "> Product Name and Price</a> </div> ]]> </Content> </Module> </code>
Upload and Test
You’ll need to save your gadget—weekly-feature.xml would be fine name—and upload it to your web server. Once you’ve up loaded it, the gadget will have a URL like this: http://www.yourstore.com/weekly-feature.xml.
To test your gadget let’s use iGoogle. If you don’t have an iGoogle account but already use any of Google’s services, including Analytics, Gmail, or AdWords, you should find a link to iGoogle on your My Accounts page.
Once iGoogle has opened:
- Select “Add stuff.” In most themes, it will be on the right-hand side of the page.
- Once the “Add stuff” page opens, look for the “Add feed or gadget” link at the bottom of the left-hand column.
- Click it and a dialog box will open. Just type in your gadgets URL— http://www.yourstore.com/weekly-feature.xml—and click “Add.”
- A new dialog box will appear. Select “OK.”
- Now click on the “Back to iGoogle home” link at the top of left-hand column.
- You should see your gadget.
Promoting Your Gadget
Now that you have a working “Weekly Feature” gadget, you’ll want to promote it. Link to it on your website and add it to module directories like the Unofficial Google Modules list and Google’s gadget directory. Remember to keep updating your gadget weekly by changing the product image and the link.