1

I am fairly new to Joomla (using for less than a year) and I need to find a way to place a script tag before the tag in joomla. This is for marketing (call tracking) purposes. I have seen some recommend the Flexi Code plugin/module, but I also saw it didn't give you a way to add it before the tag. Normally, I'd add it to the template but the interesting dynamic here is that I only need it on certain pages, not all.

Any suggestions to help me get this done, would be greatly appreciated.

1

If you can edit your template add this right before the closing tag.

<jdoc:include type="modules" name="analytics" style="none" />

Then you can use FlexiCustom Code module and publish it to the analytics position on any menu item you want.

  • Thank you - it turns out, the script needed to be added to every page so it became a bit easier to manage from there. I appreciate you responding. – kjkentner Sep 29 '16 at 21:15
3

If you have access to your template, you can use the following code

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');

and after at the right place in the template

if($itemid == 544) //replace 544 by your itemid
{
?>
   // tracking code here
<?php
}
?><body>

You can adapt the condition to match the page you need to track

  • Thank you - it turns out, the script needed to be added to every page so it became a bit easier to manage from there. I appreciate you responding. I'll keep this in mind in the event I need to come back to it. – kjkentner Sep 29 '16 at 21:15
  • add it on the main index.php of your template and it'll be available everywhere and don't forget to accept my answer if it help you. – Pierre-André Vullioud Sep 30 '16 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.