Hi,
I was searching around a LOT about how to redirect the "Ask a Question" form to a custom Thank You Page for tracking conversion, and I did't really find an answer to that.
I've figured it out so, here is my solution:
ATM I'm using Joomla version, 3.9.18., VirtueMart 3.6.10, Horme 3 Temlpate.
First of I've created a Thank You Page of course.
Then in /templates/horme_3/html/com_virtuemart/askquestion/mail_confirmed.php file I had:
// Check to ensure this file is included in Joomla!
defined ( '_JEXEC' ) or die ( 'Restricted access' );
if(VmConfig::get('usefancy',1)){
$onclick = 'parent.jQuery.fancybox.close();';
} else {
$onclick = 'parent.jQuery.facebox.close();';
}
?>
<div class="productdetails-view">
<p>
<?php echo vmText::_('COM_VIRTUEMART_ASK_QUESTION_THANK_YOU'); ?>
</p>
<button class="btn btn-primary" type="button" onclick="<?php echo $onclick ?>"><span class="glyphicon glyphicon-remove"></span> <?php echo vmText::_('COM_VIRTUEMART_CLOSE'); ?></button>
</div>
<script>
jQuery('button').click(function(){
jQuery('#form-collapse', parent.document).collapse('toggle');
});
</script>
and under this line:
<?php echo vmText::_('COM_VIRTUEMART_ASK_QUESTION_THANK_YOU'); ?>
I've added the following code:
<?php redirect(JURI::base() . '/'."thank-you-page");
function redirect($url)
{
echo '<script type="text/javascript">';
echo 'window.top.location.href = "https://yourwebsite.com/thank-you-page"';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
echo '</noscript>';
exit;
}
?>
I hope it's going to be useful for some of You.
Thank you for your attention.
Best wishes,
Shyntaxx.
Cool, thanks for sharing!
Sent from my S41 using Tapatalk
Thank you very much for the shared code.
I have a few comments below.
The idea of redirecting the customer outside the e-shop website is bad from a marketing point of view. I don't want the customer to leave, I want him to stay at the e-shop and buy something.
Redirecting the form to the thank you page (just to measure the form) is a bad idea for the same reason.
The programmer made an adjustment here so that the e-shop behaved the way he wanted - so that it programmed well. He didn't think about marketing and business at all.
There are many ways to measure form submission (we use 2 ajax boostrap forms with a URL change in a popup without redirection and a thank you message on the product detail and with a reprogrammed recaptcha for multi-display).
For example:
- set up and call up a virtual page and insert the measuring code into it
- use GTM and set the display delay for it
I appreciate the comment!
- set up and call up a virtual page and insert the measuring code into it
- use GTM and set the display delay for it
Not sure if I understand these two options .. Although I've read about "GTM datalayer push" for an another example ..
Anyway .. at first I've set it to open the thank you page in a new browser tab, but then it got blocked by the browser ..
Some links for your study:
https://www.optimizesmart.com/tracking-virtual-pageviews-google-tag-manager-v2-complete-guide/
https://www.theleverageway.com/blog/4-ways-to-track-conversions-when-your-url-does-not-change/ - 2. Analytics On-Click Virtual Pageviews
https://www.analyticsmania.com/post/google-tag-manager-form-tracking/ - AJAX Form Tracking with Google Tag Manager
https://www.bounteous.com/insights/2015/08/27/ajax-event-listener-google-tag-manager/?ns=l
https://www.bounteous.com/insights/2015/07/01/track-forms-without-thank-you-pages-using-gtm/
and on GTM you must setup 2000 ms waiting for trigger for write tracking code to virtueal page.