|
|
Documentation Wiki > ExactTarget > Content > AMPscript > Using Google Charts in Email Messages Using AMPscript
Using Google Charts in Email Messages Using AMPscriptFrom $1This document contains conceptual and procedural information about including Google Chart information in an email message. NOTE: Google Chart API usage may change without notification. Please review the latest Google Chart information at the link above to ensure these instructions will still function. What are Google Charts in Email MessagesThe Google Chart API allows you to provide information from a data extension and get a dynamic chart to include in your email message as an image. Why Use Google Charts in Email MessagesUsing the Google Chart API, you can include a dynamic chart with up-to-date information (taken at the time of the send) in your email messages. Depending on the data extension you use, you can either send the same chart to all subscribers in the send or use information particular to each subscriber to create the chart. How to Use Google Charts in Email MessagesYou must create three elements to include a Google Chart in your email message:
The Data ExtensionThe data extension structure varies depending on your chart needs. In this example, the data extension contains fields for 5 individual cases and 5 individual months. The AMPscriptThe AMPscript below takes the information from a data extension and concatenates that information into a URL for use with the Google Chart API. %%[
Var @url, @row
Set @row = Row(LookupRows("Graph Data",_SubscriberKey),1)
Set @url = "http://chart.googleapis.com/chart?chs=300x225&chxr=0,0,10&chxt=y&chds=0,10&chd=t:"
Set @url = Concat(@url,Field(@row,"cases_1"))
Set @url = Concat(@url,",",Field(@row,"cases_2"))
Set @url = Concat(@url,",",Field(@row,"cases_3"))
Set @url = Concat(@url,",",Field(@row,"cases_4"))
Set @url = Concat(@url,",",Field(@row,"cases_5"))
Set @url = Concat(@url,"&cht=bvg&chl=")
Set @url = Concat(@url,Field(@row,"month_1"))
Set @url = Concat(@url,"%7C",Field(@row,"month_2"))
Set @url = Concat(@url,"%7C",Field(@row,"month_3"))
Set @url = Concat(@url,"%7C",Field(@row,"month_4"))
Set @url = Concat(@url,"%7C",Field(@row,"month_5"))
]%%
The Email MessageIn addition to the AMPscript shown above, the email message includes an HTML div section that takes the Google Chart and places it inside the email message: <div style="text-align: center; "> <img vspace="0" hspace="0" border="0" src="%%=v(@url)=%%" title="googlechart" alt="CRMpiechart" /><br /> </div> The Final ProductThe sample email below shows the information taken from the data extension and rendered into an image via the Google Chart API:
This page was last updated by Ryan Williams on Thu, 22 Mar 2012 15:40:32 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
Powered by MindTouch 2010 |