Lose tracking code every time on Wordpress update

Discussion in 'Google Analytics' started by silent_1, Apr 21, 2015.

  1. #1
    Every time when wordpress updates, I have to add tracking code again. What should I do to avoid this issue?
     
    silent_1, Apr 21, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Use a plugin instead of adding the code to your theme-files?
     
    PoPSiCLe, Apr 21, 2015 IP
  3. silent_1

    silent_1 Well-Known Member

    Messages:
    427
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    155
    #3
    PoPSiCLe
    Which plugin you will suggest?
     
    silent_1, Apr 21, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    PoPSiCLe, Apr 22, 2015 IP
  5. Adrian Robertson

    Adrian Robertson Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Where are you adding the tracking code? It sounds like it is disappearing after updating the theme (as opposed to the WP core).
    If you are editing the theme, and you are comfortable with editing the theme files (such as header.php - which I think you might already be doing anyway) then you could add the code there, BUT after creating a child theme.
    For example, if you are using TwentyFifteen as your theme, you can create a child-theme for TwentyFifteen, edit the header.php there and add in your GA code, and then further theme updates won't wipe your code out.

    On the other hand, if you are not comfortable with editing the code in header.php, using a plugin as PoPSiCLe suggested is the way to go. I just prefer to install as few plugins as I need to.

    Sometimes the theme itself will cater for adding in GA code.
    Sometimes another plugin you might already be using caters for adding in GA code.
     
    Adrian Robertson, May 17, 2015 IP