A sensor is either Analog or Digital - so you can't put an Analog sensor (such as the Air Quality and Gas Sensor) into a Digital port and assume it will work. Best to stick with the appropriate port types.
As far as I know, you can move sensors between ports of the same type. In the example you pasted, they tell you to put the sensor in port A0, simply so the code doesn't need to be updated. If you put the sensor in A1, then modify the
air_sensor variable to be
1, then the script should work.