Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

GA: tracking code interfere with jquery event.preventDefault()

Found in

EPiServer.GoogleAnalytics 1.7.1.8000

Created

Aug 24, 2015

Updated

Sep 21, 2015

Area

EPiServerCMS Modules/Add Ons/Google Analytics

State

Closed, Fixed and Tested


Steps to reproduce

Google Analytics tracking script causes links to be activated when event.preventDefault() has been placed on their click() event.


Product versions:

EPiServer.GoogleAnalytics 1.7.1.8000

EPiServer.CMS 8.11.0


Steps to reproduce

  1. Install Alloy sample site and upgrade to the specified product versions.
  2. Install Google Analytics add-on, config tracking account and track Everyone role (in CMS Admin).
  3. Replace the file ~\Views\Shared\Layouts\_Root.cshtml with the attached file.
  4. View the site in view mode, click on "Click Here" link.
Expected: The browser window should not be redirected to Google.com, because event.preventDefault() has been placed in click event:
<script>
            (function ($) {
                $("a").click(function (e) {
                    e.preventDefault();
                    alert("preventDefault executed");
                });
            })(jQuery)
        </script>

Actual: The browser window switched to google.com.


Please note that event.preventDefault() work if Google Analytics tracking is turn off in Admin mode.