Identify the page I am viewing

is_home() will do just exactly that. It returns true on the home page and false on any other page. Your solution will be to completely wrap your code above in an is_home() conditional

if ( is_home() ) {
    // Your in question comes here
}