Skip to main content

Modifying Google Analytics code

Google offers a way to use data from their display advertising network to segment users according to demographics:

https://support.google.com/analytics/answer/2444872

Enabling it requires a few things, but the blocker for me is that one of them involves changing the code to load the analytics JS (since NB uses ga.js it involves changing the source of the JS, for universal it's just adding a call before tracking the page view)

Is there a way to do this without doing all the GA code myself? And if I have to do that, how do I get the goal functionality back? 

Official response from

Sean,

You should be able to remove the NationBuilder-generated tracking code, and use Google's modified tracking code given in their example (make sure to use your actual tracking ID and site URL). Swapping out the tracking code should not affect your goals functionality.

Removing NationBuilder-generated tracking code

Go to Website → Site settings → Analytics setup, remove the Google Analytics tracking code, and save the page.

Screen_Shot_2014-05-05_at_6.32.09_PM.png

Adding custom Google Analytics tracking code

If you're using a stock theme:

  1. Go to Website → Theme → New custom theme
  2. Clone your current theme
  3. Go to Website → Current custom theme → Templates → layout.html
  4. Add the custom Google Analytics tracking code before the closing </head> tag, and save and publish the page.

If you're using a custom theme, skip steps 1 and 2 above, and simply modify your layout.html template as described in step 4.

Screen_Shot_2014-05-05_at_6.38.52_PM.png

Share this post

Showing 3 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.