Plugin Directory

Changeset 664509


Ignore:
Timestamp:
02/06/2013 08:08:44 PM (13 years ago)
Author:
segmentio
Message:

0.4.0

Location:
segmentio/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • segmentio/trunk/analytics-wordpress.php

    r663026 r664509  
    55Description: The hassle-free way to integrate any analytics service into your Wordpress site.
    66
    7 Version: 0.3.3
     7Version: 0.4.0
    88License: GPLv2
    99
     
    5353
    5454    const SLUG    = 'analytics';
    55     const VERSION = '0.3.3';
     55    const VERSION = '0.4.0';
    5656
    5757    private $option   = 'analytics_wordpress_options';
    5858    private $defaults = array(
    59         'api_key' => ''
     59        // Your Segment.io API key that we'll use to initialize analytics.js.
     60        'api_key' => '',
     61        // Whether or not we should track events for posts. This also includes
     62        // custom post types, for example a Product post type.
     63        'track_posts' => true,
     64        // Whether or not we should track events for pages. This includes the
     65        // Home page and things like the About page, Contact page, etc.
     66        'track_pages' => true,
     67        // Whether or not we should track custom events for archive pages like
     68        // the Category archive or the Author archive.
     69        'track_archives' => true,
     70        // Whether or not we should track custom events for the Search page.
     71        'track_searches' => true
    6072    );
    6173
     
    142154
    143155        // If we're saving and the nonce matches, update our settings.
     156        // Checkboxes have a value of 1, so either they're sent or not?
    144157        if (isset($_POST['submit']) && check_admin_referer($this->option)) {
    145             $settings['api_key'] = $_POST['api_key'];
     158            $settings['api_key']        = $_POST['api_key'];
     159            $settings['track_posts']    = isset($_POST['track_posts']) ? true : false;
     160            $settings['track_pages']    = isset($_POST['track_pages']) ? true : false;
     161            $settings['track_archives'] = isset($_POST['track_archives']) ? true : false;
     162            $settings['track_searches'] = isset($_POST['track_searches']) ? true : false;
     163
    146164            $this->set_settings($settings);
    147165        }
     
    212230    // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L0
    213231    private function get_current_page_track() {
    214         // The front page of their site, whether it's a page or a list of
    215         // recent blog entries. `is_home` only works if it's not a page, that's
    216         // why we don't use it.
    217         if (is_front_page()) {
    218             $track = array(
    219                 'event' => 'View Home Page'
    220             );
    221         }
    222         // A normal WordPress page.
    223         else if (is_page()) {
    224             $track = array(
    225                 'event' => 'View ' . single_post_title('', false) . ' Page'
    226             );
    227         }
    228         // An author archive page. Check the `wp_title` docs to see how they get
    229         // the title of the page, cuz it's weird.
    230         // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L0
    231         else if (is_author()) {
    232             $author = get_queried_object();
    233             $track = array(
    234                 'event'      => 'View Author Page',
    235                 'properties' => array(
    236                     'author' => $author->display_name
    237                 )
    238             );
    239         }
    240         // A tag archive page. Use `single_tag_title` to get the name.
    241         // http://codex.wordpress.org/Function_Reference/single_tag_title
    242         else if (is_tag()) {
    243             $track = array(
    244                 'event'      => 'View Tag Page',
    245                 'properties' => array(
    246                     'tag' => single_tag_title('', false)
    247                 )
    248             );
    249         }
    250         // A category archive page. Use `single_cat_title` to get the name.
    251         // http://codex.wordpress.org/Function_Reference/single_cat_title
    252         else if (is_category()) {
    253             $track = array(
    254                 'event'      => 'View Category Page',
    255                 'properties' => array(
    256                     'category' => single_cat_title('', false)
    257                 )
    258             );
    259         }
    260         // The search page.
    261         else if (is_search()) {
    262             $track = array(
    263                 'event'      => 'View Search Page',
    264                 'properties' => array(
    265                     'query' => get_query_var('s')
    266                 )
    267             );
    268         }
    269         // A post or a custom post. `is_single` also returns attachments, so we
    270         // filter those out. The event name is based on the post's type, and is
    271         // uppercased.
    272         else if (is_single() && !is_attachment()) {
    273             $track = array(
    274                 'event'      => 'View ' . ucfirst(get_post_type()),
    275                 'properties' => array(
    276                     'title' => single_post_title('', false)
    277                 )
    278             );
    279         }
     232        $settings = $this->get_settings();
     233
     234        // Posts
     235        // -----
     236        if ($settings['track_posts']) {
     237            // A post or a custom post. `is_single` also returns attachments, so
     238            // we filter those out. The event name is based on the post's type,
     239            // and is uppercased.
     240            if (is_single() && !is_attachment()) {
     241                $track = array(
     242                    'event'      => 'Viewed ' . ucfirst(get_post_type()),
     243                    'properties' => array(
     244                        'title' => single_post_title('', false)
     245                    )
     246                );
     247            }
     248        }
     249
     250        // Pages
     251        // -----
     252        if ($settings['track_pages']) {
     253            // The front page of their site, whether it's a page or a list of
     254            // recent blog entries. `is_home` only works if it's not a page,
     255            // that's why we don't use it.
     256            if (is_front_page()) {
     257                $track = array(
     258                    'event' => 'Viewed Home Page'
     259                );
     260            }
     261            // A normal WordPress page.
     262            else if (is_page()) {
     263                $track = array(
     264                    'event' => 'Viewed ' . single_post_title('', false) . ' Page'
     265                );
     266            }
     267        }
     268
     269        // Archives
     270        // --------
     271        if ($settings['track_archives']) {
     272            // An author archive page. Check the `wp_title` docs to see how they
     273            // get the title of the page, cuz it's weird.
     274            // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L0
     275            if (is_author()) {
     276                $author = get_queried_object();
     277                $track = array(
     278                    'event'      => 'Viewed Author Page',
     279                    'properties' => array(
     280                        'author' => $author->display_name
     281                    )
     282                );
     283            }
     284            // A tag archive page. Use `single_tag_title` to get the name.
     285            // http://codex.wordpress.org/Function_Reference/single_tag_title
     286            else if (is_tag()) {
     287                $track = array(
     288                    'event'      => 'Viewed Tag Page',
     289                    'properties' => array(
     290                        'tag' => single_tag_title('', false)
     291                    )
     292                );
     293            }
     294            // A category archive page. Use `single_cat_title` to get the name.
     295            // http://codex.wordpress.org/Function_Reference/single_cat_title
     296            else if (is_category()) {
     297                $track = array(
     298                    'event'      => 'Viewed Category Page',
     299                    'properties' => array(
     300                        'category' => single_cat_title('', false)
     301                    )
     302                );
     303            }
     304        }
     305
     306        // Searches
     307        // --------
     308        if ($settings['track_searches']) {
     309            // The search page.
     310            if (is_search()) {
     311                $track = array(
     312                    'event'      => 'Viewed Search Page',
     313                    'properties' => array(
     314                        'query' => get_query_var('s')
     315                    )
     316                );
     317            }
     318        }
     319
    280320        // We don't have a page we want to track.
    281         else return false;
     321        if (!isset($track)) return false;
    282322
    283323        // Clean out empty properties before sending it back.
  • segmentio/trunk/readme.txt

    r663026 r664509  
    33Tags: analytics, web analytics, segment.io, google analytics, kissmetrics, mixpanel, chartbeat, hubspot, marketo, quantcast, tag manager
    44Requires at least: 3.4
    5 Tested up to: 3.5
    6 Stable tag: 0.3.3
     5Tested up to: 3.5.1
     6Stable tag: 0.4.0
    77License: GPLv2
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4141We automatically record the different types of WordPress pages your users can visit. Things like "View About Page", "View Post", "View Author Page", etc. So you don't have to worry about recording them yourself. Just by enabling the plugin you'll already be recording all of those actions.
    4242
     43= Can I turn off the automatic event tracking? =
     44Yup! You can also turn off specific events, in case you only want a few.
     45
    4346
    4447== Screenshots ==
     
    4649
    4750== Changelog ==
     51
     52= 0.4.0 =
     53* Added settings to turn off automatic event tracking.
    4854
    4955= 0.3.3 =
  • segmentio/trunk/templates/settings.php

    r661979 r664509  
    2222                           value="<?php echo $settings['api_key']; ?>" />
    2323                    <p class="description">You can find your API key in the
    24                         Wordpress section of the Setup Guide.</p>
     24                        WordPress section of the Setup Guide.</p>
    2525                </td>
    2626            </tr>
    2727        </table>
    2828
    29         <h3 class="title">And you&rsquo;re done!</h3>
    30         <p style="max-width: 47em">Once you&rsquo;ve saved your API key, you can swap and add
     29
     30        <p style="max-width: 49em"><strong>And you&rsquo;re done!</strong> Once you&rsquo;ve saved your API key, you can swap and add
    3131            integrations right from the Segment.io interface. Any integrations
    3232            you turn on will be live within 10 minutes. No more touching any
     
    4040                   value="Save Changes" />
    4141        </p>
     42
     43        <h3 class="title">Advanced Settings</h3>
     44        <p style="max-width: 49em">These settings control which events get tracked for you automatically. Most of the time you shouldn&rsquo;t need to mess with these, but just in case you want to:</p>
     45
     46        <table class="form-table">
     47            <tr valign="top">
     48                <th scope="row">
     49                    <label for="track_posts">Track Posts</label>
     50                </th>
     51                <td>
     52                    <fieldset>
     53                        <label for="track_posts">
     54                            <input name="track_posts"
     55                                   type="checkbox"
     56                                   id="track_posts"
     57                                   value="1"
     58                                   <?php if ($settings['track_posts']) echo 'checked="checked"'; ?> />
     59                            Automatically track events when your users view Posts.
     60                        </label>
     61                        <p class="description">These will be "Viewed Post" events. And if you use any custom post types we&rsquo;ll track those too!</p>
     62                    </fieldset>
     63                </td>
     64            </tr>
     65            <tr valign="top">
     66                <th scope="row">
     67                    <label for="track_pages">Track Pages</label>
     68                </th>
     69                <td>
     70                    <fieldset>
     71                        <label for="track_pages">
     72                            <input name="track_pages"
     73                                   type="checkbox"
     74                                   id="track_pages"
     75                                   value="1"
     76                                   <?php if ($settings['track_pages']) echo 'checked="checked"'; ?> />
     77                            Automatically track events when your users view Pages.
     78                        </label>
     79                        <p class="description">These will be "Viewed Home Page" or "Viewed About Page" events for any of the pages you create.
     80                    </fieldset>
     81                </td>
     82            </tr>
     83            <tr valign="top">
     84                <th scope="row">
     85                    <label for="track_archives">Track Archives</label>
     86                </th>
     87                <td>
     88                    <fieldset>
     89                        <label for="track_archives">
     90                            <input name="track_archives"
     91                                   type="checkbox"
     92                                   id="track_archives"
     93                                   value="1"
     94                                   <?php if ($settings['track_archives']) echo 'checked="checked"'; ?> />
     95                            Automatically track events when your users view archive pages.
     96                        </label>
     97                        <p class="description">These will be "Viewed Category Page" or "Viewed Author Page" events.
     98                    </fieldset>
     99                </td>
     100            </tr>
     101            <tr valign="top">
     102                <th scope="row">
     103                    <label for="track_searches">Track Searches</label>
     104                </th>
     105                <td>
     106                    <fieldset>
     107                        <label for="track_searches">
     108                            <input name="track_searches"
     109                                   type="checkbox"
     110                                   id="track_searches"
     111                                   value="1"
     112                                   <?php if ($settings['track_searches']) echo 'checked="checked"'; ?> />
     113                            Automatically track events when your users view the search results page.
     114                        </label>
     115                        <p class="description">These will be a "Viewed Search Page" event with their query.
     116                    </fieldset>
     117                </td>
     118            </tr>
     119        </table>
     120
     121        <p class="submit">
     122            <input class="button button-primary"
     123                   type="submit"
     124                   name="submit"
     125                   id="submit"
     126                   value="Save Changes" />
     127        </p>
    42128    </form>
    43129</div>
Note: See TracChangeset for help on using the changeset viewer.