Method A
Note: Phone should be unrooted.
To verify root access,
https://play.google.com/store/apps/details?id=com.joeykrim.rootcheck
If its unrooted, then
Dial #546368#XYZ#
XYZ is exact model number, 815, 818, H810 etc
For H815,
Dial #546368#815#
Go to SVC menu > version info.
Hardware version should be 1.1.
If it's 1.0, do not get it in any case.
If it's 1.1, its safe from bootloop and you have nothing to worry and can skip Method B check.
Method B,
On the box or behind the battery. But remember box and labels can be modified, so always double check the info online via imei verification or this app.
This app is more effective to check first 3 digits of serial number.
https://play.google.com/store/apps/details?id=com.peamoon.phoneproductioninfo
The easiest thing to remember is, that this should be (1.1)BL. See the attached photo. Any G4 with hardware revision version number (1.1)BL is free from that famous G4 bootloop issues. All G4 starting with 6xx serial number are 1.1 hardware revision number and safe from bootloop issue. Mine was S/N 505, but (1.1)BL hardware revision number, so it never died.
Note: Google photos used for demo.

S/N starting with 601 is 6-01, 6=2016, 01= 1st month (January), so January 2016 date of production.
S/N starting with 505 is 5-05, 5=2015, 05= 5th month (May), so May 2015 date of production and so on.
Getting G4 with serial number starting 6xx is the easiest way to be safe.

But still avoid G4 starting with S/N 505-509, unless they are (1.1)BL hardware revision number. Double check these info at imei check website too, as labels can be modified.
Today i got S/N 604 G4 (H818P) used for a friend, so i am sure that its just one or two month used at max, since its April 2016 production, so i made an good offer to the seller which he could not refuse. Lol.
All G4 starting with serial 6 are (1.1)BL, so they are safe.
H/W (hardware revision number) located behind battery.

Content further updated