Jump to content

301 Redirects And Google Analytics


MisterMan

Recommended Posts

hi. I have searched and searched on google and am not getting it yet... there is a missing link somewhere..... I have asked my webmaster who had not gotten back to me and perhaps does not know.. I asked someone who might know but he is busy and expensive at over 1k baht an hour

and I don't want to go on a webmaster forum as I already belong here and they are so technical.

Ok..

I am hosting domainS with 1 account on (stupid) Fatcow hosting.

So I have domain1.com, domain2.com domain3.com and maindomain.com

I can easily use 2 options with Fatcow to redirect traffic..

1) I can point to another folder

2) I can redirect

All the domains are hosted in one account so when i access my account I see all my domain folders.

As domain1.com and domain2.com point to maindomain.com they do not have an indexpage.

I NEED to add google analytics to these domains or otherwise I can not see where the traffic comes from.

I have researched 301 redirects realize I have to modify my .htacess page. But which one?

The one in the main directory (outside of all the domanis) or make one for inside the domains?

and what exactly goes on it? I tried it but it is not working.

I have also contacted Fatcow but they are useless. Tech support is a guy in India calling himself Pedro with a book that has standard responses to a list of questions......simply a customer service rep.not a technician.

Thank you!

Link to comment
Share on other sites

I have no clue about Google Analytics but generally Apache is handling the .htaccess files so that it is applied to the folder where it is located and the subfolders below it.

So if you have some option that you want to apply to all folders you put it in the .htaccess file in the top folder. If you have anything that is specific for a subfolder and folder below it then you put a.htaccess file in that folder.

Martin

Edited by siamect
Link to comment
Share on other sites

I have no clue about Google Analytics but generally Apache is handling the .htaccess files so that it is applied to the folder where it is located and the subfolders below it.

So if you have some option that you want to apply to all folders you put it in the .htaccess file in the top folder. If you have anything that is specific for a subfolder and folder below it then you put a.htaccess file in that folder.

Martin

Hmm maybe they use the .htaccess file to make a redirect.

What you need is an index.htm for each of the redirected domains that is doing the google script and then redirecting to the main domain

So create the index file first and include the google anaythics script and then I guess you can use a refresh meta to redirect

<meta http-equiv="refresh" content="2;url=http://main.com/">

This one will redirect after 2 seconds... possibly the google script has been executed at that time.

Try to find something like this in the .htaccess

redirect 301 old new

and remove that line

After this it should work... but I haven't tested so be careful... backup your files before you start messing with it...

And if anyone see anything wrong here please correct me...

Martin

Edited by siamect
Link to comment
Share on other sites

i a little dont understand... you have different domain for 1 website?

if yes - you can read about suplimental result in Google search when webmaster have same situation

I have a company and then I have domains with key words.

companyname.com and keywordsdescribingproducts1.com keywordsdescribingproducts2.com

Siamect.. thank you that clarifies the .htcacess .. but I still dont know what to do. can I have a blank html for the domain I am re-routing>

Link to comment
Share on other sites

Siamect.. thank you that clarifies the .htcacess .. but I still dont know what to do. can I have a blank html for the domain I am re-routing>

I read a little about the analytics... you track the page accesses by adding a script to the files you want to track.

If you can redirect the domains to hit separate files... then you can also track those files and you can see where the hits came from.

domain2.com => index2.html

domain3.com => index3.html

These files may be in separate folders if it is easier to redirect it that way (don't know the procedures at fatcow)

inside the index2 and index3 you put the script from analytics plus the meta tag for redirection.

the meta tag is delayed so that the analytics script has time to execute

the index2 and 3 files can look something like this but you have to change some part for the analytics account and domains and so on...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>untitled</title>

<meta http-equiv="content-type" content="text/html;charset=utf-8" />

<meta name="generator" content="Geany 0.18" />

<meta http-equiv="refresh" content="5;url=http://www.main.com/">

</head>

<body>

Wait!

<script type="text/javascript">

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

</script>

<script type="text/javascript">

try{

var pageTracker = _gat._getTracker("UA-xxxxxx-x");

pageTracker._trackPageview();

} catch(err) {}

</script>

</body>

</html>

Link to comment
Share on other sites

I just threw in a working example..

go to www.siamect.com

It will wait 5 seconds and then it redirects to home.siamect.com.

if you click stop before it redirects then you have time to right click and view page source...

Google analytics works with that example:

post-98093-057609600 1282412048_thumb.pn

Edited by siamect
Link to comment
Share on other sites

Hi Thank you this makes sense.. and it is working! Thank you ..

however I have not edited the .htaccess files for this.

Does this mean that this is not a 301 direct ? And will I get penalized someone by google if I have the same key words?

Link to comment
Share on other sites

Hi Thank you this makes sense.. and it is working! Thank you ..

however I have not edited the .htaccess files for this.

Does this mean that this is not a 301 direct ? And will I get penalized someone by google if I have the same key words?

Link to comment
Share on other sites

Well strangely enough I am in the same position, I have a site with 5 url's mainly acquired for brand protection. First of all you must use 301 permanent redirects or Google will see it as duplicate content, these redirects are set up in .htaccess. Here is an excellent article on how to do, Article on 301 redirects

As for Google Analytics I have looked at that yet, but I suspect you use the same method that you use for sub-domain i.e. filters, it all depends on whether Google an see the original URL which I suspect it can.

If you just use the parked domain feature of most cpanel's the original typed domain name is seen by Google and so duplicate content which is not good.

Good luck

Link to comment
Share on other sites

Here is the solution for Google Analytics from the Google support forum Google Analytics 301 solution It's just a matter of passing Google tracking info in the redirect within htaccess, the information can be generated by Google URL builder.

It's not very straight forward because Analytics is very complex but I sure with a bit of trail and error it can be done.

Good luck

Link to comment
Share on other sites

Here is the solution for Google Analytics from the Google support forum Google Analytics 301 solution It's just a matter of passing Google tracking info in the redirect within htaccess, the information can be generated by Google URL builder.

It's not very straight forward because Analytics is very complex but I sure with a bit of trail and error it can be done.

Good luck

Nice find. Thanks for that one. :jap:

Link to comment
Share on other sites

thank you will painstakingly read through it now..

With Fatcow they have a redirct editor that changes the .htaccess and I end up with this code automatically. Is this 301?

There seems to be a lot weird gibberish.

{\rtf1\ansi\ansicpg1252\cocoartf749\cocoasubtf540

{\fonttbl\f0\froman\fcharset0 Times-Roman;}

{\colortbl;\red255\green255\blue255;\red115\green18\blue14;\red241\green156\blue66;}

\paperw11900\paperh16840\margl1440\margr1440\vieww13280\viewh8660\viewkind0

\deftab720

\pard\pardeftab720\ql\qxxxxl

\f0\fs36 \cf0 Redirect \cf2 301\cf0 domaina.com/index.html http:

\i \cf3 //www.maindomain.com/index.php}

Edited by MisterMan
Link to comment
Share on other sites

Well I have to say that every time I tried my hosts (siteground.com) cpanel utility to do the redirect it came back a Apache error. The code you have pasted looks like it's just encoded. I would concentrate on one job at a time, the 301 stuff is easy, just make sure you don't overwrite something that you need in your htaccess file, download it first from the public_html folder of the main domain.

Get it working and then look at Google.

Link to comment
Share on other sites

Hi Thank you this makes sense.. and it is working! Thank you ..

however I have not edited the .htaccess files for this.

Does this mean that this is not a 301 direct ? And will I get penalized someone by google if I have the same key words?

Correct... it is not a 301 redirect.... it is just a refresh into a second URL.... sorry if 301 is important this is not the way to go and you should listen to phuketMike instead...

Martin

Link to comment
Share on other sites

So where does the analytics script go? stays in the index of old domain being redirected or in the .htaccess

Thanks so much for everyone help

I think it can go into the htaccess where the redirection is...

see the link from phuket Mike

http://www.google.co...a44d2e338&hl=en

They say something like

Rather than redirecting to ....

I don't know if this is enough but i think so...

Martin

Edited by siamect
Link to comment
Share on other sites

urg it is not working............

do I set , via stupid Fatcow , my domain to point also to the normal folder or to redirct this way?

IM confused now. I put the code in like he said but then in his sample there was no space in front of one of the

[NC] and then he said Be sure to include a space before each [NC] and he said remove the space between the lines. So I did all that. however I had to remove the first paragraph as it was already on my .htaccess but a bit different. I tried it this way to and it did not work

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain.com [NC]

RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^www.domain.com [NC]

RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

Currently for the company name domain and the actual domain this is the code on the .htacess

Options +FollowSymlinks

RewriteEngine on

RewriteBase /

### re-direct companynamedomain.com/index.html to http://www.actualhostedsitedomain.com/index.php/ ###[/b

What am I doing wrong?

Also can I do this if I dont have an index page?

Link to comment
Share on other sites

As domain1.com and domain2.com point to maindomain.com they do not have an indexpage.

I NEED to add google analytics to these domains or otherwise I can not see where the traffic comes from.

No you shouldn't add GA to these. You should simply 301 redirect them, and any traffic that comes via those sites will retain the referrer info which will show in GA. You wont be able to tell that traffic came through those redirects, but I cant see any major reason why you'd want to track that?

I have researched 301 redirects realize I have to modify my .htacess page. But which one?

The one in the main directory (outside of all the domanis) or make one for inside the domains?

If you are using virtual hosts then you should update the .htaccess file inside each domain folder.

and what exactly goes on it? I tried it but it is not working.

Try this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.[newdomain].com/ [R=301,L]

Replace [newdomain] with the domain you wish to redirect to, and also update .com if necessary.

Link to comment
Share on other sites

From what I can see the original .htaccess file has nothing you need.

So currently you a domain hosted on fatcow, you have a site with an index file and other linked files lets call it www.mydomain.com.

You then purchase www.newdomain.com the name only no hosting.

First step make sure this new domain is Parked via Fatcow control panel, when you have done this typing www.newdomain.com should bring up pages from www.mydomain.com but www.newdomain.com will remain in the browser address bar as the site name. You don't want this because Google with see it as duplicate content and rank accordingly.

So leaving the domain Parked you now need to add the redirect commands in htaccess.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^newdomain.com [NC]

RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

Once you have one this again test in browser, what should happen is your original site should come www.mydomain.com, if it does that's it and now repeat lines 2 and 3 for all other add-on domains not the original.

The Google script stays in the original index file. The second part once this is working is to look at the Google support forum link to get the addon domains to pass url parameters so that you can track in Analytics. I haven't done the Google side yet.

Link to comment
Share on other sites

hmmmm

I get unlimted domain hosting with my Fatcow account so they are not parked.. I could put content or not..

So many people say so many different things. I am exhausted... think I will shell out for a webamaster as mine doesnt not seem to get it.

Link to comment
Share on other sites

hmmmm

I get unlimted domain hosting with my Fatcow account so they are not parked.. I could put content or not..

So many people say so many different things. I am exhausted... think I will shell out for a webamaster as mine doesnt not seem to get it.

Right you have a hosting account with primary domain pointing to it. You want your other domains to also point to it, this is called Parking, on your cpanel you should have an option to park domains, please try it with one first, I know what I am talking about because I did it 2 nights ago with 4 domain names pointing to 1 and it works. Ok I was using a different hosting company but they are all very similar. Parking domains has nothing to do with your hosting account being unlimited or not.

If you want me to help directly PM me, I will help for free.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.







×
×
  • Create New...