AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
5.7K members online now
5.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Google analytics breaks the layout of website

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi All,

          Our website http://store.medpotnow.com/ doesnt render properly,it loads as http://store.medpotnow.com/?_ga=1.173419623.574203455.1456790591 (as an external link on a WordPress site) but its breaking the layout of the website. Could anyone tell me what the issue is and how this can be fixed?

1 Expert replyverified_user

Re: Google analytics breaks the layout of website

Top Contributor
# 2
Top Contributor
Hi Mohammed :-)

I've noticed that cross domain tracking seems to be setup between the domain and the store subdomain using the linker method (this is what is appending the .ga=1.173419623.574203455.1456790591 to the urls.
Is there a reason cross domain tracking has been configured between the two rather than just a subdomain tracking setup.
Is there another different domain that is being tracked to as well?
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google analytics breaks the layout of website

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
I am aware of the cross domain tracking but wasn't sure why it was enabled...Is there a way to remove the urls from being appended while still enabling cross domain linking?. If not could you also tell me how to disable the cross domain tracking?

Re: Google analytics breaks the layout of website

[ Edited ]
Top Contributor
# 4
Top Contributor

If you are not cross domain tracking between another different domain or subdomain of another domain
eg someothersite.com or subdom.someothersite.com. as opposed to store.medpotnow.com and medpotnow.com
then cross domain tracking is not necessary


what you are after is a subdomain tracking setup.


The only thing needed for that to work is the same tracking code snippet must go on both store.medpotnow.com and justmedpotnow.com
and the cookie domain must be set to auto. No special linker setup is necessary

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-45194180-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>

Make sure to clear your cookies etc before testing

 

Not sure why the tracking code appending the GA number to the urls would break the site

Having said that, there are quite a few typeerrors and 4oh4s with some of the js code etc

to do with the slider/carousel and checkout etc

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google analytics breaks the layout of website

Top Contributor
# 5
Top Contributor
just to add too, there is also an asynchronous tracking snippet for a different tracking id combined with the tracking script for the above tracking id on the store subdomain
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google analytics breaks the layout of website

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Thank you for the answer, I am a newbie to web hosting/programming and am in the learning phase :-)

Could you tell me where exactly should i put in the code snippet you posted, as it does it go on the server and if so in which format?

Re: Google analytics breaks the layout of website

Top Contributor
# 7
Top Contributor

Code needs to be edited both on the main domain and subdomain.
Main domain seems to be WordPress.
This code needs to be removed:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-45194180-1', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['store.medpotnow.com', 'medpotnow.com'] );

  ga('require', 'displayfeatures');
  ga('send', 'pageview');

</script>

And replaced with the following:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-45194180-1', 'auto');
ga('send', 'pageview');
</script>

Display features no longer needs to be enabled via the tracking code but you may need to make some changes to the analytics account setup - more info on that here:
https://support.google.com/analytics/answer/2444872?hl=en

The store subdomain seems to be Joomla?
I've not used Joomla in eons however this here should help you with installing the tracking code on the subdomain

http://www.templatemonster.com/help/joomla-2-5-xjoomla-3-x-how-to-add-google-analytics-tracking-code...

This code needs to be removed 

<!-- alex: edited ga code -->
<!-- BEGIN GOOGLE ANALYTICS CODEs -->
<script type="text/javascript">//<![CDATA[
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-45194180-2']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','UA-45194180-1','auto',{'allowLinker':true});ga('require','linker');ga('linker:autoLink',['store.medpotnow.com','medpotnow.com']);ga('require','displayfeatures');ga('send','pageview');
//]]></script>
<!-- END GOOGLE ANALYTICS CODE -->

 

and replaced with this same code

 

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-45194180-1', 'auto');
ga('send', 'pageview');
</script>

You then also need to create a new View for Property UA-45194180-1 and apply the following filter:

  • Filter Type: Custom filter > Advanced
  • Field A: Hostname Extract A: (.*)
  • Field B: Request URI Extract: (.*)
  • Output To: Request URI Constructor: $A1$B1

Click Save to create the filter.

 

This prepends the hostname to the Request URI in the GA Content reports etc.

So pages and pageviews etc report correctly

Is UA-45194180-2 a Property that is also being used as i notice there is also tracking code for that too?

If so, then add the following script into the store site as well

 

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-45194180-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

 

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google analytics breaks the layout of website

Top Contributor
# 8
Top Contributor
also to add.. nto sure how you are currently installing the tracking code on the main domain with WordPress?
Check if the current active WP theme has an admin option to add scripts to the head of the site
In this instance I would not add the tracking code via an analytics plugin as they usually change the name of the global object and other stuff
and because the subdomain is not WordPress you dont want a plugin possibly causing a conflict between the two different platforms being used.

If the theme doesnt have an option to do that re the scripts. then the following plugin will allow you to do that
without any additional bells and whistles added in
https://wordpress.org/plugins/header-and-footer-scripts/
Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google analytics breaks the layout of website

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭
Our subdomain is on Magento and not on joomla....I know where i have to edit the code but what i dont understand is why there is UA-45194180-2 and UA-45194180-1........The account number is set to UA-45194180-2 under Google API settings in magento, does the account number have to be same on both primary and sub domains?...I have changed the same to UA-45194180-1 in magento too now but want to be sure if its the right way....Also thank you for the detailed answer, I was able to learn a lot :-)

Re: Google analytics breaks the layout of website

Top Contributor
# 10
Top Contributor

Hi :-)
I'm completely confused by the now current setup
The now current code on the subdomain will not work:

 

<!-- alex: edited ga code -->
<!-- BEGIN GOOGLE ANALYTICS CODEs -->
<script type="text/javascript">//<![CDATA[
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-45194180-1']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','UA-45194180-1','auto',{'allowLinker':true});ga('require','linker');ga('linker:autoLink',['store.medpotnow.com','medpotnow.com']);ga('require','displayfeatures');ga('send','pageview');
//]]></script>
<!-- END GOOGLE ANALYTICS CODE -->


It combine both the previous version of the tracking code and current version of the tracking code for the same tracking id .UA-45194180-1
This will cause a conflict and between the two different versions and will not work correctly.

I'm also not sure why cross domain tracking is being used and not subdomain tracking as per my suggestion
Cross domain tracking should not be needed and is what is appending the parameters to the urls as per your first post in this thread.
Subdomain tracking setup will allow the sharing of referral and session data between the main and subdomain,

unless you are also tracking to another different domain then cross domain tracking should not be used.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here