NAME

    Dancer::Plugin::Piwik - Generate JS code for Piwik

VERSION

    Version 0.05

SYNOPSIS

    In your configuration:

      plugins:
        Piwik:
          id: "your-id"
          url: "your-url"
          username_session_key: 'piwik_username'

    The username_session_key is optional. If set, the plugin will look into
    the session value for the given key and set that as the tracked
    username. You probably want to that in an hook.

    In your module

        use Dancer ':syntax';
        use Dancer::Plugin::Piwik;
    
        # if use'ing Dancer::Plugin::Auth::Extensible;
        hook before => sub {
            if (my $user = logged_in_user) {
                session(piwik_username => $user->username);
            }
            else {
                session(piwik_username => undef);
            }
        }

CONFIGURATION

    Two keys are required:

 id

    The numeric id of the tracked site (you find it in the Piwik admin).

 url

    The url of the tracking site, without protocol and without trailing
    slash. E.g.

     mysite.org/stats

EXPORTED KEYWORDS

    All the following keywords support the boolean argument ajax. Instead
    of the javascript, a perl structure will be returned.

 piwik

    Return generic code for page view tracking. No argument required.

 piwik_category(category => "name")

    Generate js for category pages. Requires a named argument category with
    the name of the category to track.

 piwik_view(product => { sku => $sku, description => $desc, categories =>
 \@categories, price => $price })

    Generate js for flypages. Expects a named argument product, paired with
    an hashref with the product data, having the following keys

    sku

    description

    categories

      (an arrayref with the names of the categories). An empty arrayref can
      do as well).

    price

      The price of the item

 piwik_cart(cart => \@items, subtotal => $subtotal)

    Generate js for cart view. Requires two named arguments. The cart
    argument must point to an arrayref of hashref products, with the same
    keys of piwik_view, and an additional key quantity.

 piwik_search(search => { query => 'query', category => 'category', matches
 => 10 }};

    Generate js for search results. Requires a search argument with the
    data to pass to piwik. The only mandatory value is query.

 piwik_order(cart => \@items, order => { order_number => $id, total_cost =>
 $total, subtotal => $subtotal, taxes => $taxes, shipping => $shipping,
 discount => $discount }

    Generate js for the receipt. Two required arguments: cart is the same
    as piwik_cart, while order is an hashref with the following keys:

    order_number (required)

    total_cost (required)

    subtotal (optional)

    taxes (optional)

    shipping (optional)

    discount (optional)

AUTHOR

    Stefan Hornburg (Racke), <racke at linuxia.de>

BUGS

    Please report any bugs or feature requests to bug-dancer-plugin-piwik
    at rt.cpan.org, or through the web interface at
    http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Piwik. I
    will be notified, and then you'll automatically be notified of progress
    on your bug as I make changes.

SUPPORT

    You can find documentation for this module with the perldoc command.

        perldoc Dancer::Plugin::Piwik

    You can also look for information at:

      * RT: CPAN's request tracker (report bugs here)

      http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Piwik

      * AnnoCPAN: Annotated CPAN documentation

      http://annocpan.org/dist/Dancer-Plugin-Piwik

      * CPAN Ratings

      http://cpanratings.perl.org/d/Dancer-Plugin-Piwik

      * Search CPAN

      http://search.cpan.org/dist/Dancer-Plugin-Piwik/

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

    Copyright 2014 Stefan Hornburg (Racke).

    This program is free software; you can redistribute it and/or modify it
    under the terms of the the Artistic License (2.0). You may obtain a
    copy of the full license at:

    http://www.perlfoundation.org/artistic_license_2_0

    Any use, modification, and distribution of the Standard or Modified
    Versions is governed by this Artistic License. By using, modifying or
    distributing the Package, you accept this license. Do not use, modify,
    or distribute the Package, if you do not accept this license.

    If your Modified Version has been derived from a Modified Version made
    by someone other than you, you are nevertheless required to ensure that
    your Modified Version complies with the requirements of this license.

    This license does not grant you the right to use any trademark, service
    mark, tradename, or logo of the Copyright Holder.

    This license includes the non-exclusive, worldwide, free-of-charge
    patent license to make, have made, use, offer to sell, sell, import and
    otherwise transfer the Package with respect to any patent claims
    licensable by the Copyright Holder that are necessarily infringed by
    the Package. If you institute patent litigation (including a
    cross-claim or counterclaim) against any party alleging that the
    Package constitutes direct or contributory patent infringement, then
    this Artistic License to you shall terminate on the date that such
    litigation is filed.

    Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
    AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
    THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
    YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
    CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
    CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.