gelegentlich
occasionally
Sometimes, but not regularly; from time to time.
Wir gehen gelegentlich zusammen ins Kino, aber nicht jede Woche.
We occasionally go to the movies together, but not every week.

occasionally
Loading your saved state.
occasionally
Sometimes, but not regularly; from time to time.
Wir gehen gelegentlich zusammen ins Kino, aber nicht jede Woche.
We occasionally go to the movies together, but not every week.

The word 'gelegentlich' (occasionally) is derived from 'die Gelegenheit' (opportunity/occasion). So it describes something that happens when a suitable opportunity arises, and not according to a fixed plan.
Wenn sich eine Gelegenheit ergibt, besuche ich meine alte Heimatstadt.
When an opportunity arises, I visit my old hometown.
In the meaning 'manchmal' (sometimes), 'gelegentlich' (occasionally) is flexible. It can stand at the beginning of the sentence to emphasize frequency, or in the middle of the sentence.
Gelegentlich gehe ich nach der Arbeit spazieren.
Occasionally, I go for a walk after work.
In the formal meaning 'anlässlich' (on the occasion of), 'gelegentlich' (on the occasion of) takes the genitive. This structure is found almost only in written language, for example in official speeches or reports.
Gelegentlich des Firmenjubiläums wurde eine Feier für alle Mitarbeiter organisiert.
On the occasion of the company anniversary, a celebration was organized for all employees.
You can recognize the meaning 'anlässlich' (on the occasion of) by the fact that 'gelegentlich' (on the occasion of) stands directly before a noun in the genitive that names a specific event. The more common meaning 'manchmal' (sometimes), by contrast, refers to the frequency of an action.
Gelegentlich seiner Reise nach Berlin besuchte er auch das Brandenburger Tor.
On the occasion of his trip to Berlin, he also visited the Brandenburg Gate.
here
'hier und da' and 'gelegentlich' both describe something that happens only now and then. 'gelegentlich' is more neutral and a bit more precise when it comes to time: something happens from time to time, but not regularly. 'hier und da' sounds more colloquial and can refer not only to time, but also to different places. In reports, at work, or in somewhat more formal sentences, 'gelegentlich' often fits better. In casual conversation, 'hier und da' sounds natural.

Für das Projekt arbeiten wir gelegentlich auch nachmittags zusammen.
For the project, we also occasionally work together in the afternoons.
Zu Hause probiert das Team hier und da neue Programme aus.
At home, the team tries out new programs here and there.