Tracker 2.x

Legacy documentation for Tracker 2.x.

This tag uses the Google Charts API and returns a graphical representation of views statistics for a given channel entry.

{exp:tracker:charts} 

Parameters

The following parameters are available for use:

entry_id=

entry_id="{entry_id}" 

This parameter tells Tracker which entry to pull statistics for. The entry ID can be hardcoded, passed through an embed, or parsed from the URI using {segment_3}. This parameter or the url_title parameter is required.

url_title=

url_title="{url_title}" 

This parameter tells Tracker which entry to pull statistics for. The URL title can be hardcoded, passed through an embed, or parsed from the URI using {segment_3}. This parameter or the entry_id parameter is required.

channel=

channel="articles" 

This parameter is required when using the url_title parameter method, as URL titles are NOT unique across channels.

site=

site="clothing" 

This parameter is required when using MSM on your site (if Multiple Site Manager is installed).

tracker_timeframe=

tracker_timeframe="last 30 days" 

This parameter allows you to display a specific timeframe interval, or a timeframe from today, backward, from which to count tracked views for the given entries. It accepts values like: today, yesterday, current week, current month, current year, and last 30 days.

tracker_timeframe_start=

tracker_timeframe_start="2012-01-01 12:00 PM" 

This parameter allows you to set a start date/time of when to count tracked views for the given entries. This parameter accepts both standard or easy-to-use text date formatting. Used in conjunction with the tracker_timeframe_end parameter, though NOT necessary.

tracker_timeframe_end=

tracker_timeframe_start="2012-01-31 11:59 PM" 

This parameter allows you to set an end date/time of when to count tracked views for the given entries. This parameter accepts both standard or easy-to-use text date formatting. Used in conjunction with the tracker_timeframe_start parameter, though NOT necessary.

tracker_chart_data=

tracker_chart_data="month" 

This parameter allows you to specify the type of data that will be displayed in the chart. Options are: day, week, month and year.

chart_title=

chart_title="The Greatest Chart Evar!" 

This parameter allows you to customize the title of the chart.

chart_type=

chart_type="bar" 

This parameter allows you to set the type of chart to show. Options are: bar or line.

chart_height=

chart_height="300" 

This parameter allows you to set the height of the chart, in pixels.

chart_width=

chart_width="600" 

This parameter allows you to set the width of the chart, in pixels.

chart_bgcolor=

chart_bgcolor="ffffff" 

This parameter allows you to customize the background color of the chart.

chart_grid=

chart_grid="no" 

This parameter allows you to add a grid to the chart. Default is yes.

chart_numbers=

chart_numbers="yes" 

This parameter allows you to display the actual number values to each peg/bar on the chart. Default is no.

chart_class=

chart_class="my_chart" 

This parameter allows you to add a class attribute to the returned image.

chart_id=

chart_id="my_chart" 

This parameter allows you to add an ID attribute to the returned image.

google_chart_NAME=

google_chart_NAME="value" 

All of the Google Chart parameters are available. For a more exhaustive list of features, visit the Google Charts Feature List documentation.

To construct these Google Charts parameters as Tracker:Chart parameters, just take the value you see in the Parameters column on the Google Charts page, and prepend it with google_chart_. So for example, chbh will become google_chart_ + chbh = google_chart_chbh. For the value of the parameter, refer to the Description and Syntax column for syntax.

Examples

The following are a few different examples of how you can use this tag:

Display “Hits per Month for Past Year” Stats Chart for an Entry

{exp:channel:entries channel="articles" require_entry="yes"}
    <h2>{title}</h2>
    <p>{body}</p>
    {if no_results}
        <p>Sorry, no entry was found.</p>
    {/if}

    <h3>Statistics for this entry:</h3>
    {exp:tracker:chart
        entry_id="{entry_id}"
        tracker_chart_data="month"
        chart_type="bar"
        chart_width="800"
        chart_title="Hits per Month for the Year"
        tracker_timeframe="past_12_months"
    }

{/exp:channel:entries}

It will appear something like this:

Display “Hits per Day for Past 30 Days” Stats Chart for an Entry

{exp:channel:entries channel="articles" require_entry="yes"}
    <h2>{title}</h2>
    <p>{body}</p>
    {if no_results}
        <p>Sorry, no entry was found.</p>
    {/if}

    <h3>Statistics for this entry:</h3>
    {exp:tracker:chart
        entry_id="{entry_id}"
        tracker_chart_data="day"
        chart_type="bar"
        chart_width="800"
        chart_title="Hits per Day for the Past 30 Days"
        tracker_timeframe="past_30_days"
    }

{/exp:channel:entries}

It will appear something like this: