-
Notifications
You must be signed in to change notification settings - Fork 27
Tracking
The click events are done by JavaScript code. Therefore the script factfinder/tracking.js is included (by the layout/factfinder/tracking.xml) into the search result page only if tracking is enabled in the backend. (These conditions are handled by the method Flagbit_FactFinder_Model_Observer::addTrackingHandles, which is triggered by the event controller_action_layout_load_before (=> configured inside the config.xml). If the conditions match, this method will add the layout-handle factfinder_clicktracking_enabled into the page, which is defined inside the layout/factfinder/tracking.xml).
The inclusion of that script won't do anything by its own. The initialization of this script is done inside the templates factfinder/tracking/click.phtml and factfinder/tracking/recommendation.phtml (represented by the classes Flagbit_FactFinder_Block_Tracking_Click respectively Flagbit_FactFinder_Block_Tracking_Recommendation) which are also included by the layout handle described above. It will initialize the tracking script with this data:
- The css-selector which should match on the html element that contains all products. (=> performance improvement)
- The relevant tracking information for each product added as a JSON object (see the method
getJsonDataObject()). The keys of these objects are the product IDs. - Mapping data for each product. The mapping is done from the product URL to the ID.
- This mapping data is used by the tracking script to find all matching products URLs and attach a click event to it. Later when the click happens it looks up the relevant tracking information by the known ID and sends this data to the specified tracking URL:
- URL where the tracking should be sent to.
- Flag "asynchronous": set to false so the AJAX request should not be done asynchronous. This is necessary as the click request happens directly before the browser wants to go to the next page (because of the click). The most browsers will interrupt an asynchronous request and the event would never be tracked.
The tracking request will be handled by one of the methods at the Flagbit_FactFinder_ProxyController without much logic - just sent to the correct destination of FACT-Finder.
At the etc/config.xml there is are "event handlers" defined for the events sales_order_place_after (=> cart) and checkout_cart_product_add_after (=> checkout). In both cases a method of the class Flagbit_FactFinder_Model_Observer is defined which handles the particular tracking event:
-
addToCartTracking: send the cart event for the currently added product directly to FACT-Finder (request is done immediately) -
addOrderDetailsToQueue: the checkout events are not sent to FACT-Finder immediately but saved into a database table instead (=> table definition). This queue is handled by a scheduled job that must be triggered by Magento's Cronjob system. For each call the methodprocessOrderQueueof the same Observer class is triggered, which will read all entries of the database table and send each event to FACT-Finder and delete it afterwards. The configuration of this cronjob is also inside the config.xml at the xml node.../crontab/jobs/factfinder_tracking_queue_processing.
About FACT-Finder and this extension
- Installing the module
- Configuration
- Data Export
- Export CMS Pages
- Channel configuration in FACT Finder installation wizard
- Setup Cronjob
- Fallback
- Adding functionality
- Customize Suggest
- Integrate Campaigns
- Use a different slider
- Secondary Search
- ASN customization
- Data Export Implementation
- Tracking
- Recommendation Engine
- Tag Cloud
- Mobile API Support
- Verify if FACT-Finder settings are working?
- Why Frontend is showing Magento’s standard search?
- How to setup Cron-Job for tracking?
- How to fix Error "String could not be parsed as XML"?
- Allowed Memory Size Exhausted during product export
- Click tracking is not working