Choose the script that works for you. You can:
Use a simple Extended Events trace to get deadlock graphs via the sqlserver.xml_deadlock_report event
Use a Server Side SQL Trace to get deadlock graphs (for older versions of SQL Server, or people who like SQL Trace)
Use a (much more verbose) Extended Events trace to get errors, completed statements, and deadlock graphs. You only need something like this if the input buffer showing in the deadlock graph isn’t enough, and you need to collect the other statements involved in the transactions. You do this by matching the transaction id for statements to the xactid for each item in the Blocked Process Report. Warning, this can generate a lot of events and slow performance.
I’d default to script #1 and look at #3 in extreme scenarios.