ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Need help to setup Google Analytics correctly with a EE site?

August 19, 2009 9:15pm

Subscribe [2]
  • #1 / Aug 19, 2009 9:15pm

    arnoldc

    122 posts

    SEO newbie.

    I have a site like http://www.abc.com and EE will redirect to a home page say http://www.abc.com/index.php/home.

    In the referring site section of Google Analytics, Google would say abc.com as my top referring site. 

    I suspect it is because EE’s redirection is causing that as Google now thinks the referring link is from abc.com to my actual page embedded with tracker code.

    Wonder if anyone runs into an issue like this?

  • #2 / Aug 20, 2009 6:45am

    Neil Evans

    1403 posts

    are you saying that this is what happens? or are you saying this is what you think will happen?

    If someone accesses your website from the root of the domain i.e. http://www.abc.com then by default your Linux server will automatically default to load index.php but not as a redirect. The EE setup will then load your default template group and default template inside that… but the URL will not redirect it will stay as http://www.abc.com

    Therefore this is what analytics will record it as, no distorted referrer information.

    If you are experiencing this, then it can only mean that your analytics are not being displayed on the root domain http://www.abc.com but they are on the EE site http://www.abc.com/index.php/home
    My gues would be in this case you have a funny setup, an index.html in the way, or similar.

  • #3 / Aug 20, 2009 3:06pm

    arnoldc

    122 posts

    Thanks for enlightening me.  Indeed this is a redirect problem on my side.

    My site is driven by Page module and in order to set a particular page to be my home page, I have a redirect in the index file of the template group to the specific URL alias to be served by the Page module.  So in my case, I have the following code in my index.php file.

    <head>
    
    <title>Redirect</title>
    
    <meta http-equiv="refresh" content="0; url={site_url}index.php/home">
    
    </head>

    I can’t recall but that’s the trick I learn in order to set a home page to work with Page Module.  Now my next question is how do I set a home page using Page module otherwise.  Any insight?

  • #4 / Aug 20, 2009 3:21pm

    Neil Evans

    1403 posts

    i am not sure on the best method, as i see what your saying about using the page module… but you should be able to achieve the same thing without the redirect using clever labelling of template ?

    for example (and this is probably bad messy advice) but setup a template group “home” make it default, then setup index in that group to include your correct template specifying the right weblog article. but no don’t do that it is very messy….

    the refresh from above - is that SEO friendly?
    i would try and do the same via a .htaccess file and rewrite rule… clever setup of this could then also eliminate the index.php part.
    Alternatively you might be able to speak to your host and see if you can setup the default homepage (to be index.php/home) through .htaccess or php.ini files…

  • #5 / Aug 20, 2009 9:51pm

    arnoldc

    122 posts

    Wonder if a proper 301 redirect may solve the issue on hand.  Instead of using meta refresh, I’ll try PHP 301 redirect and hopefully the referring site information will be preserved this way.  We’ll see….

  • #6 / Aug 21, 2009 5:22am

    Neil Evans

    1403 posts

    but to do a 301 re-direct he would need to place that on the default page index.php as used by EE. so unless he went through the hassle of renaming the index.php, or changing the default home to another php and redirect…etc… hence using a .htaccess to do it blind would probably be best in my eyes a least.

  • #7 / Aug 21, 2009 10:00am

    ender

    1644 posts

    I’ve used the pages module on a number of sites, and use GA for all of them.  generally what I do is remove the index.php with an htaccess rewrite rule, and then specify the page URI for the home page entry to be “/” in the pages module.  then you don’t have to redirect them from domain.com to domain.com/home in the first place.

  • #8 / Aug 21, 2009 2:44pm

    arnoldc

    122 posts

    but to do a 301 re-direct he would need to place that on the default page index.php as used by EE. so unless he went through the hassle of renaming the index.php, or changing the default home to another php and redirect…etc… hence using a .htaccess to do it blind would probably be best in my eyes a least.

    No, not on the global index.php but the index.php inside a template group.

    EE allows one to specific the index template of any template group to be my site’s home page? But since my site is driven by the Pages module (URL alias /home, /about-us ...etc) and this module has no function to set a home page, I have been using meta refresh in the index template to my desired ULR. (e.g http://abc.com/index.php/home)

    This works but I will lose the original referrer in the process as indicated by Google Analytics.  Now you bought up the use of 301 re-direct using mod_rewrite.  This can also be achieved by using PHP script inside the index template.  I am hopefully the switch from meta refresh to 301 re-direct inside the index template is good enough for Google to preserve the referrer.

  • #9 / Aug 21, 2009 2:48pm

    arnoldc

    122 posts

    I’ve used the pages module on a number of sites, and use GA for all of them.  generally what I do is remove the index.php with an htaccess rewrite rule, and then specify the page URI for the home page entry to be “/” in the pages module.  then you don’t have to redirect them from domain.com to domain.com/home in the first place.

    Thanks for your suggestion and it seems this is the right way to do.  However, my client’s site has been running over a year and is not using clean URL.  Would it cause any problem if I switch to clean URL now with all the old links referencing by external sites.

  • #10 / Aug 24, 2009 2:28pm

    ender

    1644 posts

    set up a 301 redirect from index.php/home to the new index page to make sure nobody’s bookmarks break, but all the other pages on the site should continue to work fine with or without index.php specified.  test to make sure of course.

  • #11 / Aug 31, 2009 4:00pm

    arnoldc

    122 posts

    I confirmed PHP header redirect works with Google Analyics.  Now I can see all the traffic sources.

    In brief, I changed the content of the index.php of my default template group from meta refresh to:

    Header( "HTTP/1.1 301 Moved Permanently" ); 
    Header( "Location: index.php/home" ); 
    exit;

    Hope this will help someone out there encountering a similar problem using the Pages module.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases