Tuesday, November 5, 2024

Using Dynamic JavaScript Source Reference for Embedded Content and Syndication

As blogs and RSS feeds gain more popularity amongst the mainstream, content aggregation and integration seems to be the next logical step in the right direction. Most of the content integrating technology till date has been focused on the “Back-End” – XML-RPC, SOAP, RSS feeds etc. We’ll show a very easy, yet very effective, way of enabling content integration using dynamic JavaScript.

This article is targeted towards content producers and application delivery organizations. It is imperative that these providers make it easy to include their content as part of other’s websites. This would not only increase exposure of their content, but also establishes them as a content provider.

For example:
You produce a “Top 10 List” every week, and you would like to other partner sites to display that list “Embedded” as part of their website. The conventional solution to the problem would be – to expose a Web-Service (XML-RPC, SOAP, RSS News feed XML) and ask your partners to write back-end integration code. They can take the XML and convert that into HTML and publish it as part of their website.

This puts a lot of burden on the “Consumer” or “Partner” to write the necessary code to get the content from you. This creates a barrier-to-entry. Especially smaller companies that do not have the development resources to do this are left in the dark.

What we propose is that, you can achieve the same kind of content integration with one single line of JavaScript. We ask the content produces to render “Dynamic JavaScript”. All the consumers and partners have to do is to reference the JavaScript code on their website.

Let’s take an example:

<SCRIPT SRC=http://js.questionpro.com/akira/JavaScript?id=7264>
</SCRIPT>

The JavaScript that is rendered is coming from the Content Producer’s website embedded within the “Partners” website.
In this example, QuestionPro produces the HTML code necessary to put out a “Rate this Item” survey. Consumers of the content can put this line of JavaScript on their web page, and a dynamic web form will be presented to the end user.

The Dynamic JavaScript can be rendered just as you render dynamic html. You can use the variety of server-side dynamic content rendering technologies like ASP, Java Servlets, PHP, Cold Fusion, Perl etc. Instead of having a MIME-TYPE of “text/html”, simply change that to “application/vnd.javascript”.

The JavaScript that gets pushed out should have the necessary code to print out the html. For example, the following code prints “Hello World”: –

document.write(<B>Hello World</B>');

Real-Life Example Implementations of this Technology

QuestionPro
QuestionPro is an online site allowing users to create and deploy online surveys using a Point-and-Click interface. One of the challenges that we faced was the ability to let users “Embed” their surveys as part of their website – instead of having a link to their survey. We had to make it easy for our users to include the content.

Our first solution was to provide the HTML for the survey, so that it can be “Cut” and “Pasted” into their websites. This proved to be ineffective, because every time the survey format changed (user added a question, or reformatted a question using the user interface) the whole process had to be repeated.

We then proceeded with the Dynamic JavaScript approach. In this solution we wrote a Java Servlet that served out a piece of JavaScript code that would render the survey for the user dynamically. All users had to do to embed their survey within their websites was a one line JavaScript call :

<script src="http://js.questionpro.com/akira/JavaScript?id=7264"> </script>

This would render their survey (Survey ID 7264) as part of their website. This would always render the “Latest” version of their survey. So, if users wanted to change the format, all they had to do is to change the format using the point-and-click interface by logging on to QuestionPro.com.

The technology used for pushing out the dynamic survey through the JavaScript interface was Java Servlets combined with some open-source API’s like Apache’s Jakarta Struts and Velocity.

Google Ad-Sense
By now, some of you must have heard of Google’s new AdSense program. This allows you to put Google Ad’s as part of your website. The Ad’s are targeted to the keywords relevant to the content on your web page. This also uses the exact same Dynamic JavaScript technology.

To Enable AdSense on your site, you do a similar thing – reference JavaScript code on Google’s Website.

The JavaScript code figures out the URL (of your webpage) and, since Google has the content for a particular URL in their database, it can lookup what keywords make sense for your content. They then print out the Ad’s that have keywords that are close to the content on your website, embedded as part of your web page!

Recently, Google also launched “Tracking” tools that enable you to track click-through conversion rates also. These tracking tools are nothing but integrated references to JavaScript code on Google servers that you call from your HTML pages.

We think that it is imperative that content producers, who want syndication, think about the “Ease of Content Syndication”. We do not want to rule out other solutions like XML-RPC, SOAP and RSS Syndication. These technically robust back-end solutions make sense when there are business rules and filtering associated with the content. It also becomes increasingly relevant if the presentation for the Dynamic JavaScript solution does not match what is acceptable. If the Dynamic JavaScript content provider does not give enough configuration options for the presentation of the content, this solution probably will not work out.

For example, with Google AdSense, if you only wanted to print one advertisement on your website, instead of the three or four that Google puts out, it would be very difficult to do that with the Dynamic JavaScript implementation. In such cases, it would make sense to get the content in a universal format like XML and then print out the first one on your web page. This is unless; the Google AdSense application itself does not allow you to configure the number of Ad’s it displays.

Content providers and application integration professionals have to weigh these factors into consideration before deciding upon their technical strategy for syndication. This has a direct impact on acceptability and your bottom-line. If content aggregation imposed an undue burden on your partners, it will not be widely accepted. Content providers using this mechanism, have to give consumers different presentation and display options – since they do not have direct access to the formatting and display.

Our experience has shown that having both the Back-End XML interfaces as well as the Dynamic JavaScript approach is the best solution. However, starting off with the Dynamic JavaScript solution and as time permits, moving to a more XML based solution is more productive both from an acceptability standpoint as well as financially. The Dynamic JavaScript solution turns more heads faster and can be easily integrated with web-sites with static html pages also. The more robust XML interface can be version 2.0 of your content syndication strategy.

Click here to sign up for technology newsletters from Murdok!

Vivek Bhaskaran is a founding member of
QuestionPro[http://www.questionpro.com] and a Principal Consultant for
eSage Group[http://www.esagegroup.com]. eSage Group is a system integrator
focused on building and delivering internet-enabled business systems. They
combine experienced professionals, enterprise technology and an adaptive,
iterative approach to provide their clients with amazing results.
As a consultant for eSage Group, Vivek has been delivering technical
integration solutions for the past 7 years.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles