The Brazilian playmaker was in danger of being branded a flop after a summer transfer from Lazio costing the Hammers up to 42 million pounds (around $55 million).
West Ham was twice pegged back by goals from Johann Berg Gudmundsson and Chris Wood and, despite a dominant display, the hosts were never assured of the points until Javier Hernandez struck their fourth goal in stoppage time.
James Tarkowski clattered Marko Arnautovic in the opening moments but the Austrian got his revenge in the 10th minute by stealing Tarkowski's under-hit back pass and slotting home before pointedly celebrating in the face of the defender.
From Burnley's first meaningful attack of the match, Ashley Westwood slipped Gudmundsson in behind and the Icelander slid the ball across Lukasz Fabianski and into the net in the 45th.
Anderson put West Ham ahead after collecting Grady Diangana's pass, taking one touch before lashing the ball through Joe Hart's legs in the 68th.
But West Ham was in danger of being left frustrated again after Wood met Robbie Brady's corner with a bullet header for 2-2 in the 77th.
Anderson should have restored West Ham's lead moments later only to clip the far post, but when Arnautovic's shot fell to his feet soon after the Brazilian made no mistake.
Hernandez capped the hosts' victory with a close-range finish at the end.