Results 1 to 8 of 8

Thread: Combine two OnClick Events? Google Analtyics + Print window command?

  1. #1
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Combine two OnClick Events? Google Analtyics + Print window command?

    Hello,

    I'm reall confused on how I would write this script. I need a Print Button to print as well as perform a tracking function with Google Analytics. How would I write this code?

    Thanks for your help!

    Code:
    <script>
    document.write("<input type='button' " + 
    "onClick='window.print()' " + 
    "onClick='javascript:pageTracker._trackPageview('/hicom/coupon');" +
    "class='printbutton' " +
    "value='Print This Page'/>");
    </script>
    I know this is wong, but how would I combine the two OnClick events?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    <script>
    document.write("<input type='button' " + 
    "onClick='window.print(); pageTracker._trackPageview('/hicom/coupon');' " + 
    "class='printbutton' " +
    "value='Print This Page'/>");
    </script>
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm...I tried that but I must have written it wrong because it wouldn't print. Thanks for the help!

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    <script>
    document.write("<input type='button' " + 
    "onClick='window.print(); pageTracker._trackPageview(\'/hicom/coupon\');' " + 
    "class='printbutton' " +
    "value='Print This Page'/>");
    </script>
    Jeremy | jfein.net

  5. #5
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm...I tried that exact code, and it breaks the Print function as I thought. Any suggestions?

    Here's the page..

    http://www.pacificaviationmuseum.org/flightcoupon.html
    Last edited by ArchangelX; 01-28-2010 at 02:11 AM.

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sorry:
    Code:
    <script>
    document.write("<input type='button' " + 
    "onClick='window.print(); pageTracker._trackPageview(\"/hicom/coupon\");' " + 
    "class='printbutton' " +
    "value='Print This Page'/>");
    </script>
    Jeremy | jfein.net

  7. #7
    Join Date
    Aug 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Awesome, that worked great. Thanks for the help...I'll remember it for future encounters. Too many 's huh?

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yea, I don't know why you're using javascript though...Glad to help you! Your welcome!

    It seems your topic is solved... Please set the status to resolved.. To do this:
    Go to your first post ->
    Edit your first post ->
    Click "Go Advanced" ->
    Then in the drop down next to the title, select "RESOLVED"
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •