= Embedding Widgets = ''This page explains two ways to embed Piwik widgets in your web pages: IFRAMEs and OBJECTs'' You can access the basic code from the '''[http://piwik.org/demo/index.php?module=Widgetize&action=index&idSite=1&period=day&date=yesterday Widgets]''' menu. == IFRAMEs == Below the '''Widget Preview''' you'll find next to the '''Embed Iframe''' label, the HTML code to embed the selected widget in an IFRAME in your web page. The widget is configured entirely through the iframe element's src attribute URL. (Do not change ''module=Widgetize'' and ''action=iframe''.) To construct the URL, you'll need (in addition to the Piwik base URL, and aforementioned module and action: * moduleToWidgetize - the module (plugin) the provides the widget * actionToWidgetize - the action (method) that provides the data for the widget * idSite - website ID * period - day, week, month, or year * date - a date (YYYY-MM-DD), date range (YYYY-MM-DD,YYYY-MM-DD), or alias (e.g., 'today') * disableLink - typically set to 1; when enabled, clicking on the evolution graph opens the dashboard to that date To set the initial chart type displayed, add the viewDataTable parameter. Valid values include: * tableAllColumns * tableGoals * table * cloud * graphPie * graphVerticalBar * graphEvolution Advantages: * No cross domain issues. * Footer controls to change chart type and export as image. Disadvantages: * More code to cut & paste. == OBJECTs == Below the '''Widget Preview''' you'll find next to the '''Embed Flash''' label, the HTML code to embed the selected widget as a Flash OBJECT in your web page. The widget is configured in a param element named, "flashvars", where the value attribute contains an escaped URL. To construct the URL, you'll need (in addition to the Piwik base URL): * module - the module (plugin) the provides the widget * action - the action (method) that provides the data for the widget * idSite - website ID * period - day, week, month, or year * date - a date (YYYY-MM-DD), date range (YYYY-MM-DD,YYYY-MM-DD), or alias (e.g., 'yesterday') * viewDataTable - generateDataChartVerticalBar, generateDataChartPie, generateDataChartEvolution Advantages: * Simple. * Compact code to cut & paste Disadvantages: * Limited to Flash-based charts (e.g., pie chart, vertical bar chart, and evolution graph) * May require a crossdomain.xml policy file. See 'misc/crossdomain.xml' for an example. == See also == * [/wiki/API Piwik web analytics API] * [/wiki/API/Reference API Reference]