Test & Target - Return HTML Content

363 views Asked by At

I am not at all a Test & Target expert. I am an Application Architect. I had a discussion yesterday with my colleague, who has huge experience in Test & Target. Today in my website the test & target content is rendered with the below mentioned steps.

1) Page loads 2) AJAX call to a T&T url is made. The response is JS with multiple lines of document.write 3) When that JS executes the content AKA html markup is rendered in the page.

Above steps does not help search engines to crawl that content. I asked my colleague if instead of sending JS(document.write) response, can you send just the content(html). If that is possible I will call for the content from the server side itself and there by append the content in response for search engine to crawl.

He says it not at all possible. I do not believe. With my experience in web application architecture, this should be possible. But my knowledge about the product is ZERO.

If anyone things that it is possible, can you please provide steps for doing it. I will share it with my colleague. Thanks a lot.

Update

As a temporary solution. Is there a way in C# .Net to run document.write JS inside an aspx file. For instance if I do document.write("test"). The text test should be part of response without the document.write js code.

Regards, Ravishankar Rajendran

1

There are 1 answers

0
Paul Sweatte On

Redefine document.write in the mbox.js file:

    document.write=function(text)
      {
      var foo = document.createElement("span");
      var bar = text;
      foo.textContent = bar;
      
      return foo.outerHTML;
      }

Then it will return a string of markup.

document.write is used by dynamic tag management only in the situations stated below.

Loading of the staging library using the dynamic tag management switch plugin uses document.write.

Workaround: Test in the staging environment by specifically referencing the staging library in the page code instead of using the dynamic tag management switch plugin to toggle between libraries.

Synchronously loading JS and HTML scripts via dynamic tag management uses document.write.

Workaround: The synchronous loading of scripts via dynamic tag management cannot avoid document.write. Thus, when this content type is being used, all third-party scripts (JS and HTML) should be loaded asynchronously in dynamic tag management to avoid document.write. Please always consider and test all code dependencies to ensure the desired behavior is still accomplished with asynchronous loading.

References