Error caused by tracking script when accessing local html

If a local html page containing piwikPRO tracking code is opened in a browser the page loads very long and eventually throws an error: Failed to load resource: net::ERR_FILE_NOT_FOUND. This is because the tracking script tries to open file://(ourInstance).containers.piwik.pro/(ourID).js instead of https://(ourInstance).containers.piwik.pro/(ourID).js which is obviously not possible.

Can you fix this?

Background:
We use piwik pro for tracking our online-help which is created using MadCap Flare. These help pages are accessible online but can also be installed locally if customers choose to do so. The locally installed html files must contain the piwik pro tracking code as well because they are exactly the same as the online version.

Hi :slight_smile:

have you tried to force the protocol directly in the snippet? It’s all about replacing src="// with src="https://. It may be needed to do this for tag manager container code snippet, as well as for all tags within the tag manager UI.

1 Like

Hi kuba,
thanks for your reply the other day, I was away for a while and only just got around to test it further.
Adding https: to the urls was also the first thing I did, but that lead me to another similar error:

Failed to load resource: net::ERR_FILE_NOT_FOUND
file://(ourInstance).piwik.pro/ppms.js

do you have any idea how I could prevent this from appearing?

This is kind of keeping us from productive use at the moment, does anyone have an idea how to prevent the error?

when the script still gets loaded from the wrong location your change to the code obviously did not work. could you share the snippet here? Or double check if really every instance of “//” got changed?

so you should not see any src="//(yourInstance).containers.piwik.pro/... in the code but only src="https://(yourInstance).containers.piwik.pro/...

If not, change the code and try again.

1 Like

Well it did work, but not completely. The previous error was because (ourID).js could not be found, now with the added protocol it is ppms.js that causes the error.

This is the edited snippet:

<script type="text/javascript">
(function(window, document, dataLayerName, id) {
window[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:"stg.start"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');
function stgCreateCookie(a,b,c){var d="";if(c){var e=new Date;e.setTime(e.getTime()+24*c*60*60*1e3),d="; expires="+e.toUTCString()}document.cookie=a+"="+b+d+"; path=/"}
var isStgDebug=(window.location.href.match("stg_debug")||document.cookie.match("stg_debug"))&&!window.location.href.match("stg_disable_debug");stgCreateCookie("stg_debug",isStgDebug?1:"",isStgDebug?14:-1);
var qP=[];dataLayerName!=="dataLayer"&&qP.push("data_layer_name="+dataLayerName),isStgDebug&&qP.push("stg_debug");var qPString=qP.length>0?("?"+qP.join("&")):"";
tags.async=!0,tags.src="https://***.containers.piwik.pro/"+id+".js"+qPString,scripts.parentNode.insertBefore(tags,scripts);
!function(a,n,i){a[n]=a[n]||{};for(var c=0;c<i.length;c++)!function(i){a[n][i]=a[n][i]||{},a[n][i].api=a[n][i].api||function(){var a=[].slice.call(arguments,0);"string"==typeof a[0]&&window[dataLayerName].push({event:n+"."+i+":"+a[0],parameters:[].slice.call(arguments,1)})}}(i[c])}(window,"ppms",["tm","cm"]);
})(window, document, 'dataLayer', '(ourID)');
</script>
<noscript>
  <iframe src="https://***.containers.piwik.pro/(ourID)/noscript.html" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>

Hi Vincent,

we plan to allow the customization of ppms.js endpoint via UI. For now, it can be done only via support channel. Can you provide me with the instance name and website id (here or on priv)? I’ll check what can be done here.

1 Like

Thanks again for the quick reply! I would prefer a private message, but I couldn’t find a way to send you one :thinking: Is that feature maybe not activated yet?

It’s because of your trust level.

1 Like

just as an update:
the piwik pro team fixed this issue and it works great now. No errors anymore with the forced protocol. Thanks again for the very quick response and solution

2 Likes