A dye including an anchoring group in its molecular structure, said anchoring group allowing a covalent coupling of said dye to a surface, for example a surface of a nanoporous semiconductor layer, said anchoring group being represented by formula 1 wherein attachment of said anchoring group within said molecular structure of said dye is at the terminal carbon marked with an asterisk in above formula, wherein G is selected from -COOH, -SO 3 H, -PO 3 H 2, -BO 2 H 2, -SH, -OH, -NH 2, preferably -COOH, wherein A is selected from the group comprising -CN, -NO 2, -COOR, -COSR, -COR, -CSR,-NCS, -CF 3, -CONR 2, -OCF 3, C 6 H 5-m F m, wherein m = 1-5, R being H or any straight or branched alkyl chain of general formula -C n H 2n+1, n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl, wherein said dye is represented by wherein said chromophore is a squarylium dye derivative that is able to absorb in the wavelength range of visible and/or IR light, preferably in the range from 300-1200 nm or a subrange thereof, said squarylium dye derivative having aromatic ring systems Ar 1 and Ar 2 attached to a squaric acid derivative, wherein said chromophore is represented by formula 5 wherein X and Y, at each occurrence, are independently selected from O, S, NR, C 2, and wherein Ar 1 and Ar 2 are the same or different and, at each occurrence, are independently selected from the group comprising heteroaromatic systems having the formula wherein R 1 and R 2 are the same or different and are, at each occurrence, independently selected from H or any straight or branched alkyl chain of general formula -C n H 2n+1, with n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl, wherein R 3 is selected from H, -(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2) n -OR, -(CH 2) n -SR,-(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, with p= 1-4 and n = 0-12, and wherein Z is one or more moieties which, at each occurrence, is independently selected from H, or halogen, such as Cl, Br, F, I, or NO 2, NH 2, CN, SO 3 H, OH, H, -(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2)n-OR, -(CH 2) n -SR, -(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, or any aromatic and heteroaromatic system represented by the formulae wherein, n 2 = 0-12, preferably n 2 = 1-7, and wherein R 1 is selected from halogen, such as Cl, Br, F, I, or NO 2, NH 2, CN, SO 3 H, OH, H,-(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2) n -OR, -(CH 2) n -SR, -(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, R being H or p = 1-4, any straight or branched alkyl chain of general formula -C n H 2n+1, n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl. G is selected from -COOH, -SO 3 H, -PO 3 H 2, -BO 2 H 2, -SH, -OH, -NH 2, preferably -COOH, wherein A is selected from the group comprising -CN, -NO 2, -COOR, -COSR, -COR, -CSR,-NCS, -CF 3, -CONR 2, -OCF 3, C 6 H 5-m F m, wherein m = 1-5, R being H or any straight or branched alkyl chain of general formula -C n H 2n+1, n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl, wherein R 1 and R 2 are the same or different and are, at each occurrence, independently selected from H or any straight or branched alkyl chain of general formula -C n H 2n+1, with n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl, wherein R 3 is selected from H, -(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2) n -OR, -(CH 2) n -SR,-(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, with p= 1-4 and n = 0-12, and wherein Z is one or more moieties which, at each occurrence, is independently selected from H, or halogen, such as Cl, Br, F, I, or NO 2, NH 2, CN, SO 3 H, OH, H, -(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2)n-OR, -(CH 2) n -SR, -(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, wherein, n 2 = 0-12, preferably n 2 = 1-7, and wherein R 1 is selected from halogen, such as Cl, Br, F, I, or NO 2, NH 2, CN, SO 3 H, OH, H,-(CH 2) n CH 3, -(CH 2) n -COOR, -(CH 2) n -OR, -(CH 2) n -SR, -(CH 2) n -NR 2, -((CH 2) p -O) n -CH 3, R being H or p = 1-4, any straight or branched alkyl chain of general formula -C n H 2n+1, n = 0-12, preferably 0-4, or any substituted or non-substituted phenyl or biphenyl.