TRIACs look deceptively simple to use, however, a few design guidelines need to be followed.
At first glance you would think that since a TRIAC is controlling AC, it's two terminals M1 an M2 would be interchangeable. This isn't the case, if you swap M1 and M2 the TRIAC will not work. The gate drive must be referenced to M1. The schematic symbol for the TRIAC always has the gate drawn by M1, to show the asymmetry of the device.
The load should always be placed on M2 and not M1. This is important because this will cause the AC voltage to appear across the gate resistor, and will cause it to overheat and even melt. Yep, you guessed it - I've made this mistake.
Another factor is the gate drive current. The data sheet should specify gate trigger current: IGT. The gate should have a series resistor so that the current to the gate is greater than the trigger current. The resistor value should be the drive voltage divided by IGT + 20% to give it some margin. If the resistor is too small, the TRIAC will not turn on or only turn on half the cycle.