News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Re: Tracking code insertion

Started by TheBom, February 09, 2024, 05:12:51 AM

Previous topic - Next topic

TheBom

When i add my code before the </head> in this file i get a 500 error on every page of the forum.
It is almost the same as the code on the opening post, difference is ofcourse my own instance link in it.

Any advice?

Steve

My pet rock is not feeling well. I think it's stoned.

TheBom


Arantor

Change the ' for " and you should be good to go.
Holder of controversial views, all of which my own.


TheBom

Quote from: Arantor on February 09, 2024, 07:25:00 AMChange the ' for " and you should be good to go.
for? Where is that?

When i'm looking in the default theme index.template.php, on rule 188 there is a </head>
When i paste this code before this line the whole forum gives a 500 error.

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://stats.mywebsite.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Arantor

In the code you have, there are several single quotes. You need to replace them all with double quotes.

Since you are inserting it into PHP code that *also* has single quotes, that's why it breaks, because you end up intermeshing PHP and JavaScript.
Holder of controversial views, all of which my own.


TheBom

Quote from: Arantor on February 09, 2024, 07:51:06 AMIn the code you have, there are several single quotes. You need to replace them all with double quotes.

Since you are inserting it into PHP code that *also* has single quotes, that's why it breaks, because you end up intermeshing PHP and JavaScript.
Oh! That simple... Thank you it works! :)

Kindred

Please don't piggyback on someone else's support thread.  Especially since the other thread was literally years old.

And yeah....  you can't just paste code randomly.  ;)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: