Javascript code for tracking which was incorporated into Joomla installation through a Custom HTML module has no effect on Piwigo gallery. How visits to the gallery could be tracked, i.e. where the code goes in it?
Piwigo is completely external to Joomla. You will need to put the tracking code directly into Piwigo. You may want to contact the Piwigo to check if they have a plugin for analytics.