Form submit not tracked in Firefox and Safari

Safari and Firefox are not triggering events when I try to manually track submit buttons.

I’m using the Drupal piwik module and it is working for all pageviews in all browsers. The other events that I need to track are either ajax calls or form submits. They are track by all browsers apart from Safari and Firefox


// submit contact us
jQuery('.context-contact #region-content #contact-site-form .form-submit').bind('click', function(e) {
    var pageId = userSessionType + '/content/contact-page/share-submit';
    trackEvent(pageId);
  });

//Track event
function trackEvent(pageId){
    _paq.push(['trackPageView', pageId]);
}

This code works for all events that basically don’t trigger a page refresh like a form submit. If I ctrl+click the submit button in Safari (to make it open in a new tab) it will track because the page doesn’t refresh.

I have tried to wrap my event in a set timeout


setTimeout(function(){
    _paq.push(['trackPageView', pageId]);
}, 400);

and it works in Firefox but not in Safari and it breaks in Chrome.

It seems like the event eventually is canceled or lost when the next page is loaded.

If anyone had the same problem, please let me know how this was solved.

I’m currently using piwik 1.9.1 on a server I don’t have access.

Thank you

I’ve got the problem too…
But when I use trackPageView on onclick="" + href=""

If somebody knows the solution to track event with Firefox/Safari…

Thanks

Could be wrong but aren’t you missing this portion from the string.

 u+"piwik.php"

or

 u+"piwik.js" 

u+“piwik.php”

with u+“piwik.js” nothing works …

It’s a known problem/“feature” in Safari and Chrome.

For me the problem appears in FF and Safari.
I found a fix for FF but not for Safari…
I made the onclick with a JS function and I called it with onclick="myfunction(this);"
I’ll give you the function on Monday;)

function fctTrack(el){
var X = $(el).name;
}
if(!!Browser.firefox || !!Browser.safari){
setTimeout(fctTrack, 50, el);
}

and my html:
Text

Thanks !

I’ll test it and will let you know if it works


<script type='text/javascript'>
/* Détecte lorsqu'un click est fait sur la zone contenant la vidéo */
   var clic = 0;
   $('.video').mousedown(
        function() {
              if (clic == 0) {
              //Déclenche l’enregistrement de l’événement "Video"
                    _paq.push(['trackEvent', 'Video', 'Watch']);
              }
              clic++;
        }
   );
</script>

I’ve this code, and I don’t know how add this :


if(!!Browser.firefox || !!Browser.safari){ 
setTimeout(fctTrack, 50, el); 
} 

Do you have any suggestion !? I’ve already try in extract the function separatly but it doesn’t work, and i don’t have error message -_-’

Thanks a lot !

This looks to me like you are tracking video events. Google has a whole section of video tracking implementation that cold be used a guide here.

What is the video player or video CMS you are using in this case?(that could be where you apply some base code for this type of tracking) There is some great integration for lets say brightcove and Google analytics that will give you all the user interaction you could need(I m guessing you could apply it to piwik as well).

Yes, I’m tracking video events on YouTube Video. I use JQuery to detecte when a click is done on the video zone. It works perfectly with Chrome and IE, but surprisingly it does not work with FF… I did some research on Google, and I found this topic, unfortunately I don’t know how to integrate the setTimeOut with my JQuery code…

So I need to know if the Piwik Developpers are able to solve this issue ? Or if they know how get around this issue !?

Thanks :slight_smile:

I don’t know how to get around this issue, sorry - maybe someone else will help?

also I’m very interested to hear your Youtube tracking experiment :slight_smile:
Maybe you could post in our Knowledge base forum a little post explaining how you got Youtube tracking to work with Piwik?

We now have a Media Analytics plugin that tracks Videos & Audio!

More information is available here: http://www.media-analytics.net/ The plugin gives useful insights into media / video / audio analytics and adds many new reports, widgets and segments to Piwik.

Works with HTML5 video & audio, Vimeo and YouTube out of the box. Support for other players can be added easily and is documented in the developer docs. We are also happy to add support for more players upon request, please ping us. After installation the plugin will in most cases directly start tracking data see the setup guide

For a full list of features check out https://plugins.piwik.org/MediaAnalytics . Docs are available at FAQ, User Guide, Developer docs