Piwik and HostGator

Posted by piwiknoobie 

July 20, 2012 11:06PM
I tried to follow the instructions to set up Piwik with HostGator found here: http://www.warriorforum.com/adsense-ppc-seo-discussion-forum/374809-anyone-successfully-installed-wp-piwik.html

Following the instrucitons in the post from "east_coast_alex", I set it all up the way he detailed, with no problems except a "404 mod_security" warning at the beginning which "east_coast_alex" has a work around for (via the Piwik troubleshooting).

I set up everything and for some reason, it isn't tracking visits. I base this on the fact that I've been clicking around my website and Piwik hasn't recorded any visits. Any ideas?
matt [ # ]
July 22, 2012 07:44AM
Please ask hostgator to whitelist your account from the mod_security list

Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog... or start your Piwik Cloud 30 day free trial!

You may follow me on twitter & on github
July 23, 2012 11:12PM
I did this and they wanted me to go through a lengthy process to do it. Considering that I am going to be using Piwik for many of my clients (hopefully) and I don't have access to all of their hosting information, I would like help on a work around instead of going through HostGator.

I tested two domains. One it works just fine for and the other, it won't work at all. The only difference I can see is that the domain it does work for is the main domain on my shared hosting program and the other domain that isn't working is just a subdomain technically.

Would this make a big enough difference to mess up Piwik?
July 26, 2012 01:28AM
Let me clarify my issue a bit.

I have two websites: website 1 and website 2. Website 1 is working just fine. Metrics all working, etc. Website 2 is not working at all. No metrics, period.

Neither website is whitelisted by HostGator. Both websites were set up the exact same way, with the exact same code (I rechecked it again just to make sure) except, of course, with differences in the website addresses where applicable. The only difference between these two websites is website 1 is my main domain for my "Baby Plan" at HostGator and website 2 is an "add on" domain. Would this break everything down?
July 26, 2012 05:16PM
Could you list the actual domain names?

You say you have 2 websites where one is a add on domain, are you reporting into one website in piwik or have you defined 2 separate ones?

When you say add on domain do you mean its a domain that is customer set up in essence(you are acting as a host ISP for that domain VS your main domain)

I use hostgator as well and once getting by the mod security issue it works well for me.
July 26, 2012 05:26PM
I would rather not list the domain names as one is a customer's and non disclosure is a part of my policy.

Thanks for your help on this issue though and I will try to be as transparent as possible with the rest of the information.

I have two different piwik installations for the two websites. One is not feeding off of the other. I did this because if someone (maybe even Google) were to take a look at the source file or spider it, they could make connections between websites that don't need to be connected. For instance, two different clients who have no common link except that I handle their website needs.

I am confused on the second question but it is an add on domain as in the first website is the website I signed up with for HostGator. When I acquired the second website, I went in under CPanel and clicked "add on" domain and added it.

I don't understand why the workaround works for the main domain but not the add on domain.

I've tried twice with HostGator to get them to whitelist the mod_security but they tell me there's nothing mod_security is blocking for them to whitelist. How did you get them to whitelist you?
July 26, 2012 06:14PM
I didnt need to be whitelisted.

The index.php may have to be slightly different for the add on domain as typically its one level down from your main domain hence why it may be broken.

is the piwik install for each on the same level or is the add on one folder level down? think absolute path name on the server...
July 26, 2012 06:19PM
I am not a total webmaster, even on a good day haha so I will try to reply the best I can.

The piwik install is on the same level for both domain names. I just went to the file manager and clicked on the individual site. It took me to the files for that particular website and I just uploaded the piwik and installed.

Do you think I may need to list the add on website as ftp.mainwebsite.com in Piwik, if that makes sense? I know HostGator actually makes the addon a subdomain of the main domain. Do I need to reflect that in the script? So instead of www.addonwebsite.com it needs to be <ftp for addonwebsite>.mainwebsite.com?

I hope that makes sense...
July 26, 2012 06:22PM
I think the right answer to your question is both installs are on separate levels. Each Piwik install is on the same level as the index.php of the respective website.
July 26, 2012 07:35PM
ok you mention the domain so that it looks like its a sub domain and not a add on domain.

to clarify

ftp.mydomaiin.com is a sub domain of mydomain.com

An add on domain would be a different domain name like mydomain2.com

The problem may then be piwik may have a problem as the location of teh sub domains folder is different than the main domains folder so definitely check the paths structure in the php files.

Normally a subdomain i would think if the js script is the same would end up being put into the data of the main piwik install. I think since this is a sub domain the whitelisting is the way they allow a sub domain to be separated and report like a seperate true domain.

If you are looking at providing a service of tracking various sites would it not be an option to have your one domain to host piwik. Create separate JS code for each site that would be placed on all the various sites and mange it from one piwik install?

Since the code is custom per site the domains would have not real relation that google would group to.

Even if you begin to host various web sites via cpanel since they are separate domains that scenario would work.

just putting options out there as since you specify a subdomain as part of your URL then it will be grouped in a sense by google to your main domain.
July 26, 2012 11:24PM
I appreciate all of your help, I really do.

As I understand it in HostGator, an add on domain is actually just a subdomain of your main domain name. Whatever the reality is, it is definitely an add on domain that I am working with.

The reason I don't manage all of Piwik from my main domain is because if you do this, any tracking code you generate will have the main domain as a part of the tracking code. Another issue I hadn't though of is my clients will want to login to their Piwik to see their stats as well. It's much more branded if it's already on their specific domain, if that makes sense.

For my particular site, since it isn't the main domain, am I going to need to specify the true server path as the domain name instead?
July 26, 2012 11:59PM
Well, it worked.

I am going to write this for any future people with the same problem.

HostGator allows you to add on multiple domains (these are called "add on domains"winking smiley so that you can have as many domains as you want on one account. This is a pretty great feature but there is one issue to be aware of: when you add on a domain, it technically becomes a subdomain of the main domain that you first signed up for your hosting account.

Let's say when you first signed up for HostGator you singed up your main domain: "www.maindomain.com". Then, you decided to host a few other sites through your hosting program by using the "add on domain" feature. So, you added a new site caled "www.newdomain.com". www.newdomain.com is technically a SUBDOMAIN of www.maindomain.com. Considering this, Piwik won't take www.newdomain.com in the tracking code. Piwik wants the actual subdomain path you set up for your add on domain. It is easy to find this. If you click on "File Manager" in your CPanel, you will see many domain names and subdomains for you to choose from. One of those subdomains is the one you want, you just have to remember which one it is. You set up this subdomain when you went through the add on domain process. Once you remember the correct subdomain, you need to use the full subdomain in the Piwik tracking code instead of the main domain.

Once I did this, it worked. I hope this helps.
July 27, 2012 12:03AM
Also, I still need help.

Is there any way to circumnavigate having to use the subdomain? It still points to the primary domain in the source code and connects websites that shouldn't be connected. This may sound strange but I peruse the source code of competing websites all the time. I don't want anyone looking through one of my sites to see it connected to another site because it's an add on domain.

Is there another way to enable Piwik to use the "true" domain name for an add on domain?
July 27, 2012 01:52AM
Since you are hosting a domain as long as your piwik JS code is different for the new domains you should be fine. when you host multiple domains via a source like hostgator you will be using virtual hosts. The only thing that really would tie your multiple sites is the common DNS settings if someone were to pull that. (typically IP address and the name servers)

But domain1.com

and domain2.com

would otherwise appear differently for all intensive purposes
July 27, 2012 07:30AM
Unfortunately, Piwik won't allow me to use my full add on domain in the code. It won't work.

For example, let's say my add on domain is www.addondomain.com. I can't use www.addondomain.com. I've tried and the data just sits at zero and nothing happens. However, if I use the subdomain that my add on domain is registered under HostGator with, it works. This does tie me to another website because the subdomain is an extension of the primary domain. So, the website I have to enter into the code is addondomain.primarydomain.com.

This can be seen in the source code and ties me to my primary website.
July 31, 2012 11:20PM
Anyone have an idea on a workaround? This may keep me from using Piwik.

Edited 1 time(s). Last edit at 07/31/2012 11:21PM by piwiknoobie.
matt [ # ]
August 01, 2012 06:50AM
Can you please summarize the issue clearly? thx

Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog... or start your Piwik Cloud 30 day free trial!

You may follow me on twitter & on github
August 02, 2012 12:32AM

I have a shared hosting plan with HostGator. The shared hosting plan allows me to have a "primary domain" and then I can have as many other domains on the shared hosting I want via the "add on domain" function. How this basically works is they configure my "add on domain" as a subdomain to the "primary domain".


How this appears to the average user:

Primary domain url: www.primarydomain.com
Add on domain url: www.addondomain1.com

How this works technically with HostGator:

Primary domain url: www.primarydomain.com
Add on domain url: www.addondomain1.primarydomain.com

Although you can access the "add on domain" just by going to "www.addondomain1.com" it is actually set up as a subdomain and it's REAL pathway is "www.addondomain1.primarydomain.com".

Unfortunately, Piwik won't accept "www.addondomain1.com" in the script. It won't work. You have to use the REAL pathway: "www.addondomain1.primarydomain.com". This is unfortunate for someone in my case because I have a client set up as the primary domain and another, separate client set up as the add on domain. For Piwik to work on the add on domain, I have to use the "www.addondomain1.primarydomain.com" in the script. This associates two websites that I don't want to be associated at all. I do a page source look up all the time on sites and I don't want others doing that and associating two websites together that aren't associated at all except that they're both my clients.

How can I set up Piwik so that it recognizes the add on domain without having to associate it with the primary domain in the script?
matt [ # ]
August 02, 2012 01:23PM
It's not a problem for Piwik, it's that you need that the URL you put in the JS works and loads the piwik.js file. If it doesnt then it's a server configuration problem. If the website addon.com works in the browser then Piwik should work if you set in the javascript addon.com/piwik/ or whatever your piwik URL is ?

Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog... or start your Piwik Cloud 30 day free trial!

You may follow me on twitter & on github
August 02, 2012 01:39PM
You would think just "www.addondomain1.com" would work but it does not.

It will only take take the "www.addondomain1.primarydomain.com". I have tested and can confirm this. Does anyone know a way around this? By either changing some HostGator functionality or Piwik functionality?
August 02, 2012 03:36PM
Hi i have a feeling there is an issue with the posix path name on the JS code.

can you post a copy of the code(hiding any specific domain name) for me to look at?
August 03, 2012 04:06AM
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://addondomain1.primarydomain.com/piwik/" : "http://addondomain1.primarydomain.com/piwik/"winking smiley;
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"winking smiley);
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
} catch( err ) {}
</script><noscript><p><img src="http://addondomain1.primarydomain.com/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
August 03, 2012 04:27AM
in a browser can you see either domain when you enter it? I want to see when you enter either URL is there an error screen or do you see actual pages?
August 03, 2012 08:41AM
Actual pages. The way HostGator sets it up it seems like a normal hosted domain. However, their backend process is to make an "add on domain" actually a subdomain of the "primary domain" of the account.

Not sure why they do it like that but they do.
August 07, 2012 12:15AM
matt [ # ]
August 07, 2012 01:18AM
Send me a PM with your piwik URL, main site URL, the piwik login/pwd, and bug description. Thanks

Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog... or start your Piwik Cloud 30 day free trial!

You may follow me on twitter & on github
JamesT [ # ]
October 19, 2012 08:50PM
Having exact same issue. Any resolution?
matt [ # ]
October 20, 2012 06:04AM
@James, are you at hostgator? try this: [www.iwebdigest.com]

Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog... or start your Piwik Cloud 30 day free trial!

You may follow me on twitter & on github
November 21, 2012 03:40AM
Hi, I think I solved this, at least for me. I'm using hostgator and an addon domain

I was using the path of www.example.something.com instead of my real site url www.something.com in piwik as per the instructions above, but this suddenly stopped working and this is what I did:

Go to your cpanel and click add on domains.

then add a redirect so that that www.example.something.com or whatever, redirects to the actual url, eg www.something.com

Then change your piwik tracking code to now use www.something.com

and it should work!

Hope that helps!
November 26, 2012 08:20PM
stormjewel -

I was having same problem and tried your steps and now it is working fine. Thank you very much for your post.


summer [ # ]
November 26, 2012 08:37PM
This all seems really weird to me, because I never needed to jump through the hoops you all listed here to get my Hostgator account to work with an add-on domain. Just set up the add-on domain (not the subdomain), never needed to use the redirects. I had two different Piwik installs in the same account (not subdomains of my main domain), and it all worked just fine after I had them whitelist the install domains.

My only problem being on Hostgator was the resource limits for PHP once my installs started collecting a lot of data, so I had to move them after that anyway smiling smiley

Also, the way Hostgator sets up what they call add-on domains is something a lot of places use for their shared hosting setups, seemingly everyone who uses cPanel for their customers. Media Temple does something similar on their (gs) service, where each additional domain is in its own folder, but there aren't two different names for that domain setup.
dumtdump [ # ]
January 26, 2013 03:23PM
Hey setup piwik according to the following link and no domains are connected at all and you control ALL domains in ONE install and it even HIDES your installation!


------------------------ ALSO:
I am on hostgator and I gave up trying to get it whitelisted and just changed the code per the troubleshooting to use post instead of get and works fine!

If your host uses mod_security to block requests containing URLs (eg. hosts like HostGator, The Planet), you should contact your provider to whitelist your domain (or URL) and disable mod_security for your website.

THIS works no problem:
Alternately, if your Piwik is hosted on the same domain as your website being tracked, you can edit your Piwik Javascript Tracking code to force data to be sent in POST, to avoid the mod_security check. Before the line piwikTracker.trackPageView(); you can add the following line piwikTracker.setRequestMethod('POST');

Edited 1 time(s). Last edit at 01/26/2013 03:27PM by dumtdump.
dumtdump [ # ]
February 22, 2013 01:05AM
About the problem above of hostgator and the "addon domains":

copy/paste from hostgator support:
Please read before creating an Addon Domain
About addon domains
Addon Domains are handled like subdomains as far as the server is concerned, but to the outside world they are separate domains.

Addon Domains do not have their own cPanel; however, you may still create e-mail accounts, redirects, Fantastico installations, subdomains, etc.

Web stats for your Addon Domain will be found within the icon of the web stat program you select in cPanel. If you are using an older cPanel theme such as "X", you will need to look under Subdomain Stats to find the web stats.

Every addon domain is also a subdomain. You may actually load your addon domain in one of three ways:

http://addondomain.com/ (As an Addon Domain Name)
http://addondomain.com.primarydomain.com/ (As a Subdomain Name)
http://primarydomain.com/addondomain.com/ (As a subfolder)

Don't worry! Visitors will only know the link you give them; they have no way of knowing which domain is your primary domain and which is the addon domain. To your visitors, the Addon Domain appears to have its own hosting plan.
raoraj [ # ]
February 27, 2013 11:50AM
i'm facing same issue
i moved to hostgator, and their is no tracking.
just came to know that access to piwik/piwik.php is blocked
means that piwik/piwik.php is giving me 500 Error
but piwik/piwik.js is working fine.

plz guide me on this problem.
dumtdump [ # ]
February 27, 2013 01:15PM
Check that you have the correct permissions in your piwik installation.
magoo [ # ]
April 05, 2013 08:07PM
Hi everyone and thanks in advance for any help.

I also have a babycroc shared account.

I got past the mod_sec problem and got the "addondomain.com" working.

Now my problem is I cannot get "subdomain.addondomain.com" working.

How do I get over this hurdle please?

JohannaDS [ # ]
November 28, 2013 03:38PM
I had the same problem with Hostgator and finally got a reply for my ticket.

Now the installation works ... so maybe this would be useful for someone coming after me. winking smiley

Here is the email I got:


Upon further inspection, it was not mod_security that was preventing this from working. It's Bulletproof Security for Wordpress, which attempts to accomplish much of the same stuff that mod_security does anyway. This plugin created a rather convoluted .htaccess configuration, but I was able to make a small adjustment to sort of "whitelist" your piwik installation.

# Piwik installed in analytics/ -- ticket DAE-26477979
RewriteCond %{REQUEST_URI} ^/analytics/ [NC]
RewriteRule . - [S=13]

Now I'm not familiar enough with this plugin to say for sure if it's just going to overwrite my changes, so the plugin might clobber my changes unexpectedly. If it does, you might consider just disabling the plugin and/or removing its .htaccess rules -- the things that it protects against are generally already implemented by mod_security anyway.

Let us know if you require any further assistance and we'll be glad to help.


Andrew T. H.
Linux Systems Administrator II
HostGator.com LLC
Sorry, only registered users may post in this forum.

Click here to login

Free Forum support is provided by the Piwik Community. If you require any urgent or professional help, contact Piwik Professional Services team!