Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:19:02+00:00 2026-05-23T01:19:02+00:00

I am building a web-application which uses Piwik. Piwik is open-source analytics tool, similar

  • 0

I am building a web-application which uses Piwik.
Piwik is open-source analytics tool, similar to Google Analytics.

It gives tracking code similar to one mentioned below.

<!-- Piwik --> 
    <script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://example.com/" : "http://example.com/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    </script><script type="text/javascript">
    try {
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
    piwikTracker.trackPageView();
    piwikTracker.enableLinkTracking();
    } catch( err ) {}
    </script><noscript><p><img src="http://example.com/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

Following code is for Site, whose site-id is 1. Checking following lines in code.

var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);

<noscript><p><img src="http://example.com/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>

Users of my site will login to custom-made Admin Panel, and will get tracking code for the site.

Now I need to hide that tracking code.
so, I thought that I keep it in a php script. Similar to one here

<?php
  // Custom-made Analytics Script
  // File Name: custom.php

  $site_id = isset($_GET['id'])?$_GET['id']:0;
?>

<!-- Piwik --> 
    <script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://example.com/" : "http://example.com/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    </script><script type="text/javascript">
    try {
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <?php echo $site_id; ?>);
    piwikTracker.trackPageView();
    piwikTracker.enableLinkTracking();
    } catch( err ) {}
    </script><noscript><p><img src="http://example.com/piwik.php?idsite=<?php echo $site_id; ?>" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

As you can see, I have replaced site-id in JavaScript, with PHP variable which I will fetch using $_GET

Now, I will provide my users with following JavaScript code that they will put in their site.

<script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://example.com/" : "http://example.com/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "custom.php?id=1' type='text/javascript'%3E%3C/script%3E"));
</script>

My question here is, will this script have any down-points or will it break-down anywhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:19:03+00:00Added an answer on May 23, 2026 at 1:19 am

    I see two issues here:

    • If javascript is disabled, piwik will not register those visitors any more since you’re solely using JS
    • Your custom.php is vulnerable to XSS. If you want to keep it, replace:

      $site_id = isset($_GET['id'])?$_GET['id']:0;
      

      with:

      $site_id = (int)filter_input(INPUT_GET, 'id');
      

      to allow numeric input only.

    Unless you’re planning to change this code, just provide the static code with the ID hard-coded in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m building a J2EE web application which uses Oracle SSO with an OID back-end
I am building a Struts2 web application which uses tiles however I have discovered
Im building a web application which is a process management app. Several different employee
I am building a web application that uses the database for Users, Security/roles, and
I've inherited a web application which strictly uses stored procedures to do its job.
I'm building a web application that uses LAMP and the Smarty template framework. The
I'm building a music player web application which implements the HTML5 audio tag, however
I'm currently building a .net web application that uses WCF web services to allow
We are building a financial web application which requires a real time chart. Initially
I'm building a Django web application which has a lot of html generated on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.