• Resolved tom1899

    (@tom1899)


    Hi,

    Struggling a bit with some JS code from a developer. The code generated a pixel inside the body of the wordpress page. Which, I always thought was a defacto location for various scripts.

    This particular script which lives in the HEAD section generates and inserts the tracking pixel into the body section.

    The resultant page creates a gap at the top of the page in my browser which should not be there. This page is in a new site I am going to launch soon. The pixel has worked perfectly in the old site in a different theme.

    The theme developer says the tracking code needs to be in the content not the body. I have never hear of this happening before – but am not a developer. The theme developer said to go back to the Tracking Pixel developer and tell them.

    Question 1: Is the content area a normal place for a pixel to go?
    Question 2: Has anyone heard of this before?

    I’m not really sure how to approach the developer until I have a better grasp of the situation.

    Any help is really appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Strictly speaking, body and content are the same thing. But in WP parlance, when a theme developer refers to “content”, they likely mean the post specific content area, not HTML body content in general.

    Usually, a tracking pixel anywhere in the body ought to be adequate, but it’s certainly possible it’s presence outside of post content could cause display issues with a certain theme.

    It’s a little strange the gap appears at the top of the page. That usually indicates there is content that was added or output too early in the page load process. If there are no other errors aside from an undesirable gap, I would think the simplest solution would be to add some additional CSS (there’s a section for this in the customizer or style book) that hides or removes this gap.

    Thread Starter tom1899

    (@tom1899)

    Thanks bcworkz for the further clarification – that was exactly the type of response I was hoping for (intelligent and impartial).

    I have found a solution. A theme hook gives me a few different locations aside from header/footer/body. So I used opne called: generate_after_primary_content_area

    It eliminates the gap and validates per the script authors rules.

    Again, thanks for taking the time!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tracking pixel location’ is closed to new replies.