A drug delivery device comprises a medication container containing medication for delivery and a detachable unit having an electronic circuit with a microprocessor. The electronic circuit is open and non-operational when the detachable component is assembled on the drug delivery device; and the electronic circuit is closed and operational when the detachable component is detached from the drug delivery device. The detachment of the detachable unit is an essential step to operate the drug delivery device. The detachable unit can be an activation protection cap or a needle shield remover for an autoinjector device. Alternatively, the detachable unit can be a needle shield remover for a pre-filled syringe.