1

I am using new async code of Google Analytics, would it be correct to call GA.js twice in the same page, if not, is there a way to do that ?

My problem is I need to account two PageViews on a booking form using flash, the trouble is that user may not necessarilly get to the second stage but close the window n the first stage.

  <!-- Step one, I need to record a pageview -->

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-6173481-3']);
  _gaq.push(['_trackPageview', '/Step1']);
  (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +    '.google-analytics.com/ga.js'; 
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();

  <!-- Step two of the process i define a function that will get called by flash and record another pageview-->

   function completed (){

   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-6173481-3']);
   _gaq.push(['_trackPageview', '/Step2']);
  (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +    '.google-analytics.com/ga.js'; 
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

  }

1 Answer 1

1

The following should work:

  <!-- Step one, I need to record a pageview -->
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-6173481-3']);
  _gaq.push(['_trackPageview', '/Step1']);
  (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +    '.google-analytics.com/ga.js'; 
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();

  <!-- Step two of the process i define a function that will get called by flash and record another pageview-->
   function completed (){
   _gaq.push(['_trackPageview', '/Step2']);    
  }

Then call completed() from flash when desired.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.