Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a simple web page hosted in an EC2 machine, using nginx. Let's say my web page is reachable by:

http://<my_ec2_machine_static_ip>/my_web_page

I've put a Google Analytics tracking code inside my page, in the head section. After that, I've bought a domain name, and redirected it to the above address.

I've used the "invisible redirection" of my domain provider, to avoid showing the IP in the address bar, and show the domain name instead. As result, my domain provider construct a web page with a frameset that contains the real URL of my site. This way:

<FRAMESET ROWS="*,0" FRAMEBORDER=0 BORDER=0 FRAMESPACING=0>
    <FRAME SRC="http://<my_ec2_machine_static_ip>/my_web_page" NORESIZE>
</FRAMESET>

The Analytics support page for framed sites says: "We recommend that a site using frames includes the tracking code in the <head> section of the frameset (parent) page, as well as directly before the </head> tag of each child frame that you want to track."

The problem is I don't have access to the "parent" page (the page that contains the frameset code above). I just have access to my page. So, I can't put the tracking code in this "parent" page.

Is there a cleaner way of doing this? Am I going to get fake statistics for this reason?

Many thanks in advance

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Since you are using Amazon, there is no reason for you to use your domain providers "invisible redirection". Instead you should:

  1. Sign up for Amazon AWS Route 53 DNS Service
  2. In route 53, create a "Hosted Zone" for your domain
  3. Add an A records for both .yourdomain.com and www.yourdomain.com with the static IP address of your ec2 machine.
  4. Go to your domain provider and set the nameservers for your domain to the records in the NS section of Amazon Route 53.

Then you will have your domain name pointed at your ec2 server properly. No redirects or frames needed. Your site will be able to work with analytics.

share|improve this answer
    
Thanks for your response! I'm actually in the AWS free tier for 1 year. I'm not sure it the Route 53 DNS service is included or has any cost. I'll check it. –  jorgeas80 May 15 '13 at 18:24
    
Even if it isn't free, it isn't expensive. It should be about the same as the cost of domain registration. Another alternative would be to use zonomi.com I use route 53 for one of my domains and zonomi for the rest. Zonomi has the same functionality as route 53 and a has a free level of service for a single domain. –  Stephen Ostermiller May 15 '13 at 21:54
add comment

I try this and it works for me:

Insert the script code below at the end of your HTML code, just before the tag:

    <script>
        var _gaq=[['_setAccount','UA-XXXXXXXX-X'],['_trackPageview']];
        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
        g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
        s.parentNode.insertBefore(g,s)}(document,'script'));
    </script>

Change UA-XXXXXXXX-X with you tracking ID.

I prefer use this code from Initializr Template, because the Analytics code from Google, not working for me.

I've hope helped you :)

share|improve this answer
    
I don't believe this would actually work in his situation: with a framed redirect from his domain name to an IP address. There is nothing in there that even sets the domain name. –  Stephen Ostermiller May 15 '13 at 18:01
1  
Seems to work for me too... –  jorgeas80 May 15 '13 at 18:28
    
@StephenOstermiller I know it's strange, but this way works and I can collect statistics of my website. –  Carlos Azaustre May 16 '13 at 10:55
    
Glad to have confirmation. Upvoting as useful. –  Stephen Ostermiller May 16 '13 at 11:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.