Injecting Code using Javascript

Discussion in 'JavaScript' started by jonathandey, May 27, 2011.

  1. #1
    I would like to inject the Google Analytic snippet before the closing head tag when a button is clicked.

    Could you please tell me how to achieve this?
    I am using jQuery if that helps at all.

    Thanks in advanced for the reply!
     
    jonathandey, May 27, 2011 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,841
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #2
    "inject" is a phrase more commonly associated with hackers.

    Are you just trying to add specific codes to your analytics tracking?
     
    sarahk, May 29, 2011 IP
  3. jonathandey

    jonathandey Active Member

    Messages:
    112
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    I understand that, but I couldn't think of a better word.

    I just want to insert the analytic code predefined in a variable.
     
    jonathandey, May 31, 2011 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,841
    Likes Received:
    4,542
    Best Answers:
    123
    Trophy Points:
    665
    #4
    sarahk, May 31, 2011 IP
  5. jonathandey

    jonathandey Active Member

    Messages:
    112
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Ok I think I have found something
    _gat._createTracker('UA-65432-1');
    Code (markup):
    I have implemented it but I'm not sure if its working.
     
    jonathandey, May 31, 2011 IP
  6. AppleH

    AppleH Peon

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try it and post output. Thanks
     
    AppleH, May 31, 2011 IP