How and where to add VisitorAPI.js , at.js, AppMeasurement.js in angular for implementing server side | Community
Skip to main content
New Participant
March 11, 2022
Solved

How and where to add VisitorAPI.js , at.js, AppMeasurement.js in angular for implementing server side

  • March 11, 2022
  • 1 reply
  • 2945 views

I am trying to implement server-side target sdk in angular similar to this. 
https://github.com/adobe/target-nodejs-sdk-samples/tree/master/ecid-analytics-atjs-integration

 

But here in this example it has been given under template index.tpl. The same way it is not working when it is implemented in angular. How or where should i add these snippets and get the serverstate value.  Currently it is added in index.html of angular project. Have tried adding in index.html as well as in specific component. It is not working and still the target content is getting changed for every refresh.

<script>Visitor.getInstance("${organizationId}", { serverState: { visitorState }});
  </script>
  <script>
      window.targetGlobalSettings = {
          overrideMboxEdgeServer: true
      };
  </script>
  <script src="assets/js/at.js"></script> 
 <script src="assets/js/AppMeasurement.js"></script>
  <script>var s_code = s.t(); if (s_code) document.write(s_code);</script> 

There is no proper documentation or example to use target sdk server side to implement in angular.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Kishore_Reddy
Kishore_ReddyAccepted solution
New Participant
March 11, 2022
sivaram93Author
New Participant
March 14, 2022

Hi Kishore,

Thanks for quick turnaround. can i get some examples like github sample implementation or something similar to this,
https://medium.com/ida-mediafoundry/using-adobe-target-in-an-angular-application-f9c17f853dd8

As i am looking to implement via Form composer instead of VEC. Also should i have to include all those js files (at.js, visitorapi.js etc..) in index.html of angular project directory?

i am always getting value as undefined for the below required variables.

  const visitorCookie = TargetClient.getVisitorCookieName(CONFIG.organizationId);
  console.log("visitorCookie",visitorCookie);
  const targetCookie = req.cookies[TargetClient.TargetCookieName];
  console.log("targetCookie",targetCookie);
  const targetLocationHintCookie = req.cookies[TargetClient.TargetLocationHintCookieName];
  console.log("targetLocationHintCookie",targetLocationHintCookie);



Best Regards,
Siva