Order done, analytics API

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Order done, analytics API

Postby konstantinos » Mon Aug 10, 2020 3:35 pm

Hello,

We want to integrate a 3rd party analytics service, and we are asked to make API calls on certain user actions.

More specifically, we want to call API (via javascript) for the following:
1) Each product in the cart (name, price, quantity).
2) When the order is completed successfully, send the total order details (id, prices without vat, shipping costs etc)

Ideally, both the above will be called from the "Thank you for your order" page.

Could you give me a hint on the following:

1) Which is the template file I should be looking for to add the scripts?

2) Does the "Thank you" page have the complete order data I will be needing?

Thanks
konstantinos
 
Posts: 23
Joined: Wed Mar 25, 2015 3:27 pm

Re: Order done, analytics API

Postby admin » Tue Aug 11, 2020 5:27 pm

hello, there is a system "opc tracking" in OPC which handles proper triggerers especially for thank you page.

a general problem in VM is that there is no such thing as "thank you page" since each plugin can render it's own thank you page and the default "order_done" is only used before redirect to a payment (like paypal or similar)

there are at least 2 solutions in OPC how to handle this:
1)
you can enable OPC tracking (in it's own config which enables 2 plugins in your joomla)
you can create a copy of g.alalytics tracking into your own OPC plugin:

rename all "analytics" to your "ownplugin"

analytics.xml -> set your own name + create required config fields
analytics.php -> this is loaded at the thank you page with all the order data available. OPC's plugin are detecting order status changes (and thank you page) with:
-- customer context changes (within same request)
-- via cookie to history changes whch can refresh the page when the order status change is detected outside customer context (i.e. customer is on the site and there is an IPN done at the background - this forces the page refresh)
-- vie cookie to history - at next customer page hit (up to 1 month from the cookie initialization)
- in OPc tracking -> your own plugin set up order statuses for which the code should be triggered (no statuses selected means it won't get loaded)
analytics_cart.php -> this is loaded when cart is a loaded - you can measure abandoned carts with this one

analytics_first.php -> this is one is prepended before any other event , it includes "global" code such as the GTM iframe or others
analytics_last.php -> this one is loaded as last if an event occured (available events are - always when _first exists / category / product details / cart / order )

analytics_category.php -> loaded at category page
analytics_product.php -> loaded at product details page

for add to cart monitoriing you will need a javascript and possibly ajax (note that if the ajax is loaded too early, it can break session if your server doesn't support session locking properly -> i.e. pls use file sessions )
for add to cart tracking via JS you can get inspired at \components\com_onepage\trackers\js\gtm.js or at FB or Analytics "_product.php" file.

2)
another way to run a code at thank you page is to use an "article at thank you page with special variables" and put your javacript into this article directly. OPC will use the tracking plugins to detect the thank you page and display the article as needed.

Other solutions:
3)
you may want to alter the payment plugin's thank you page directly to trigger your own code as far as the order status is already updated when the customer returns from the payment gateway.

4)
For server to server solutions (not in customer context) we have asynchronious system which:
- can send commend to the database which is executed at the later stage via cron

the systems are located in /administrator/components/com_onepage/export/templates (plugin.php + plugin.xml + plugin.php.ini )
while the plugin.php is loaded during order status change and this can then register the order further.

the asynchronious system supports also buttons at the VM order backend where you can use them to send the data directly to your other server (or generate emails, etc... )

for examples of these you can check Sherpa Implementation + Trusted Shops after Shipped triggerer and many more.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x

cron