Site Search Tracking

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23579
    Sandy
    Sandy
    Participant

    Hi Ernest,

    Our client wants to track Site Searches, however they don’t use Google Analytics but Piwik (as they need to stay privacy-compliant),
    is it possible toget this working with Ajax Search Pro?

    https://developers.piwik.pro/en/latest/analytics/tracker_object.html#tracking-functions
    https://piwik.pro/

    Thanks in advance,
    -Sandy

    #23591
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Sandy,

    Based on their documentation, it could be possible to connect the two plugins via the API. I would start off with something like this:

    add_action('wp_footer', 'asp_custom_tracking_scpt');
    function asp_custom_tracking_scpt() {
      ?>
      <script>
      jQuery(function($){
        $(".asp_main_container").on("asp_search_end", function(event, id, instance, phrase) { 
          // Run your tracking function here
          // ..based on their docs, maybe:
          trackEvent('Action', 'Live Search', 'Phrase', phrase);
        });
      });
      <script>
      <?php
    }

    I have absolutely no idea if this does anything, but it should call the trackEvent() function (based on their API), when the search ends.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.