Mobile app version of vmapp.org
Login or Join
Barnes591

: Google Analytics and framesets 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

@Barnes591

Posted in: #AmazonEc2 #Frameset #GoogleAnalytics #Nginx

I have a simple web page hosted in an EC2 machine, using nginx. Let's say my web page is reachable by:
<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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Barnes591

2 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

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


Sign up for Amazon AWS Route 53 DNS Service
In route 53, create a "Hosted Zone" for your domain
Add an A records for both .yourdomain.com and yourdomain.com with the static IP address of your ec2 machine.
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.

10% popularity Vote Up Vote Down


 

@Harper822

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 :)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme