문제

I'm trying to gather either an event or custom variable tracking on the turn.js plugin through Google Analytics. Right now it's set up for a custom variable. I'm trying to track time on page turns. In the plugin there is an event handler called 'turned'. This is an event that runs when the page has been turned. I have my analytics set up here, but they are collecting to google incorrectly. Any help with this is appreciated. I have the JS event below:

when: {

    turned: function(event, page, view) {

        _gaq.push(['_setCustomVar', 1, 'Page Spread Scope 1', 'page spread ' + view, 1 ]);
        _gaq.push(['_trackPageview']);

        }

      }
도움이 되었습니까?

해결책

Not sure what exact data you want but I think it is something like this. Just wrote it right now, so haven't fully tested it. I did debug it and it seems to work fine. It should record the page+pagenumber and it should record the time on that page with the new _trackTiming method

For your page turn this snippet:

<script>
$('#magazine').turn().bind("click", function(event){
pagenumber = $('#magazine').turn('page');
myTimer();  
});
</script>

And then this in your head somewhere.

<script>
var startTime = new Date().getTime();

function myTimer(event) {
  var endTime = new Date().getTime();
  var timeSpent = endTime - startTime;
  var hourInMillis = 1000 * 60 * 60;

  if (0 < timeSpent && timeSpent < hourInMillis) {
  _gaq.push(['_trackTiming', 'page-timer', 'time-on-page', timeSpent, pagenumber, 1]);
  _gaq.push(['_trackPageview', 'turnedpage-' +pagenumber]);
  }
 return this;
}
//wiremedia.nl
</script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top