google analytics - where to put code? (7 posts)

  1. motionid
    Posted 9 years ago #

    Wanting to use google analytics.
    Wondering where I should put the code so I can see the results.
    Anyone know?

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    In header template.

  3. chaaban
    Posted 9 years ago #

    someone just asked this question today ...


    also google tell you where to place it :

    Copy the following code block into every webpage you want to track.
    Click in the box below to select all code. Next, copy it. Then, paste the code segment after the <head>, <meta> tags and before the </head> tag on each page you are planning to track.

    in your themes header.php should be fine ...

  4. NuclearMoose
    Posted 9 years ago #

    This raises an important point about the structure of WordPress and its theme system.

    If I wanted to use Google Analytics, or any other kind of web service that requires a similar call to a remote script, then I have to duplicate the call in all of the themes I wish to use. Is there a way to set this up so that I can store my links to remote services like this external to the themes? This is too much maintenance to bother with, otherwise.

  5. estjohn
    Posted 9 years ago #

    could you put the code itself in a .js file or a php file and have it called somwhere in your header? then when called, would run whateve ryou put in the file whether it is that or another?

  6. Joshua Sigar
    Posted 9 years ago #

    Too much maintenance if you switch theme everyday. In that case, a plugin that utilize the hook wp_head can maintain a single source that could be included in any active theme.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.