Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Code does not work #5762

Closed
anonymous-matomo-user opened this issue Aug 19, 2008 · 17 comments
Closed

Javascript Code does not work #5762

anonymous-matomo-user opened this issue Aug 19, 2008 · 17 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@anonymous-matomo-user
Copy link

The code Piwik gave me to insert in my web pages after installation was this:

```



Free analytics piwik



```

This code did not work. It results in a pkBaseURL variable not defined error.

I modified it to:

```




Free analytics piwik




```

and now it works.

Server running Piwik:

Windows Server 2003
Apache
mySQL
PHP
(The standard XAMPP installation: http://www.apachefriends.org/en/xampp-windows.html)
Keywords: javascript

@anonymous-matomo-user
Copy link
Author

This problem has been discussed without a fix on, at least, two other tickets:
#5738
#5759

@mattab
Copy link
Member

mattab commented Sep 7, 2008

jj026799, what browser were you using to result in a “undefined” javascript error with the first code?

This code is live on piwik.org and it’s working fine with all common browsers. This is also similar to the code used by google analytics. please give more information so we can repeat the bug.

@anonymous-matomo-user
Copy link
Author

Attachment:
[piwik_urlUndefined.gif](http://issues.piwik.org/attachments/5762/piwik_urlUndefined.gif)

@anonymous-matomo-user
Copy link
Author

I’ve attached the error and the Microsoft JavaScript Debugger screenshot.

Here is the Virtual Host information I have in the httpd.conf file:

```
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin julia.jacobs (at) hdsupply.com
ServerName intranetstats.hdsupply.net
DocumentRoot C:/xampp/htdocs/piwik
<Directory “C:/xampp/htdocs/piwik”>
Options None
AllowOverride None
Order allow,deny
Allow from all

```

I have the code in a footer include (footer.html)

The website is www.hdsupply.com

I am viewing it through IE 6

I don’t get the JavaScript error in Firefox but Piwik is not picking up the data.

Piwik is running on a Windows NT 5.2 / Standard XAMPP php / mySQL / Apache setup: http://www.apachefriends.org/en/xampp-windows.html. I know I mentioned Windows 2003 previously but its Windows NT.

Although the site that’s giving the error is accessible externally, the site with the Piwik stats and admin console is on the company intranet.

Thanks you for looking into this! Can you shoot me an email when you have a chance to view www.hdsupply.com so I can restore the Piwik code and not the modified code that works?

Because its a company site I have to make sure the stats data keeps coming . . .

Let me know if there’s any other information you need to help.

Julia Jacobs

@mattab
Copy link
Member

mattab commented Sep 12, 2008

Julia, when I look at your website with IE6 I have other javascript error (line 154 object expected). I would first fix the other issues and then paste the piwik code. Really, this should work (it works now on piwik.org if you can confirm that you don’t see javascript errors)

@robocoder
Copy link
Contributor

Julia: with the modified code, Firefox’s Error Console says piwik_log is undefined. So it appears the site may already be dropping some stats. Please try running your page through W3C’s markup validator. It’s a free online service:

http://validator.w3.org

@anonymous-matomo-user
Copy link
Author

First off, thank you so much matt and vipsoft for looking into this frustrating problem. I apologize for my late response.

I think the best thing for me to do (which I should have done in the beginning) is use an external company site that does not get much use or traffic (looking into this now), put the piwik generated javascript on the pages and report any problems in this ticket.

I’ll update this ticket when this has been completed.

Thanks again for all of your help with this wonderful tool.

JJ

@anonymous-matomo-user
Copy link
Author

Okay here’s the external site with the piwik generated javascript code:

http://polarpipe (dot) ca

I’m still getting the pk url undefined error (second attachment).

This site is running off of the same piwik server / web server that the hdsupply.com site is . . .

Thanks,
JJ

@anonymous-matomo-user
Copy link
Author

Attachment: Error from polarpipe.ca
[pkBaseURLUndefined.gif](http://issues.piwik.org/attachments/5762/pkBaseURLUndefined.gif)

@robocoder
Copy link
Contributor

The problem is the backslashes before the double quotes. \"

This acts as a literal escape and thus, code is embedded in the text string. Change the ends of these URIs to /", i.e.,

var pkBaseURL = ((“https:” == document.location.protocol) ? “https://intranetstats (dot) hdsupply (dot) net/” : “http://intranetstats (dot) hdsupply (dot) net/”);

<noscript><p>Free analytics <img src=“http://intranetstats (dot) hdsupply (dot) net/piwik.php” style=“border:0” alt=“piwik”/></p>

@anonymous-matomo-user
Copy link
Author

That did it. I want to modify the piwik code so piwik generates javascript with / at the end of the URLs but I can’t figure out how to do it. The LogStats/javascriptTag.tpl has that {$piwikUrl} variable which seems to have the \ within it. I’m not much of a developer so I can’t figure out how to change this.

Any suggestions?

Thanks,
JJ

@robocoder
Copy link
Contributor

It should already be appending / — see modules/Url.php’s getCurrentUrlWithoutFileName().

@anonymous-matomo-user
Copy link
Author

Unfortunately Piwik is generating javascript with the ‘\’ in it.

Could this be because the piwik code resides on a Windows NT server (with Apache / php / perl – standard LAMP configuration)? I know there are issues with forward vs. backslashes with running apps native to Linux on Windows.

See latest attached file / screenshot for the javascript generated by Piwik.

Thanks,
JJ

@anonymous-matomo-user
Copy link
Author

Attachment: Piwik Generated Javascript
[wrongslash.gif](http://issues.piwik.org/attachments/5762/wrongslash.gif)

@robocoder
Copy link
Contributor

Attachment:
[Url.patch](http://issues.piwik.org/attachments/5762/Url.patch)

@anonymous-matomo-user
Copy link
Author

Yay! Yay! Patch is great!

Now Piwik is my best friend!

If I could only get the GeoIP plugin to work, but thats another ticket :)

Thank you for sticking with this issue and making the lives of those forced to run this in Windows much easier.

@mattab
Copy link
Member

mattab commented Oct 10, 2008

thanks vipsoft for the patch, you rock, trunk now fixed

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

3 participants