A method and apparatus for drug product tracking (or other pharmaceutical, health care or cosmetics products, and/or the packages or containers they are supplied with) using diffraction grating-based encoded optical identification elements 8 includes an optical substrate 10 having at least one diffraction grating 12 disposed therein. The grating 12 has one or more colocated pitches Λ which represent a unique identification digital code that is detected when illuminated by incident light 24. The incident light 24 may be directed transversely from the side of the substrate 10 (or from an end) with a narrow band (single wavelength) or multiple wavelength source, and the code is represented by a spatial distribution of light or a wavelength spectrum, respectively, or a combination thereof. The encoded element 8 may be used to label any desired item, such as drugs or medicines, or other pharmaceutical or health care products or cosmetics. The label may be used for many different purposes, such as for sorting, tracking, identification, verification, authentication, anti-theft/anti-counterfeit, security/anti-terrorism, or for other purposes. In a manufacturing environment, the elements 8 may be used to track inventory for production information or sales of goods/products. Such labeling provides product identification at the pill or liquid medicine level, which provides traceability of these products to their manufacturer, thereby reducing counterfeit products in the marketplace. Also, the elements 8 may be incorporated into a film, liquid, coating or adhesive tape at attached to the product package.