You are here

seoH1

Used by the following Containers: 
Variable Type: 
Custom Javascript
Grabing all H1 in the page a making an array with it if multiple, or just the content of the h1
	function() {
    var h1 = document.body.getElementsByTagName('h1');
  	var seoH1Numbers = {{seoH1Number}};
  	

	if( seoH1Numbers == 1) {
      	// one H1 was found
      	return h1[0].innerText
    } else if (seoH1Numbers > 1) {
      	// more than one H1 found
    	var i;
  		var h1List = [];
		for ( i = 0; i < seoH1Numbers; i++ ){
    		h1List.push(h1[i].innerText)
    	}
  		return h1List;
    } else {
    	return 'no H1 on page';
    }
}