Add dynamic script to metadata

CM1 - I need to add some script to top of every page that pulls a few unique values from the page for reporting.

Question 1 - How do I assign a page some unique vaules to be pulled into that script?
Question 2 - How do I pull that unique page information into the script?

I know I can add static script to meta data area of template or page, but I want that script added to template area to be dynamic based on what values have been assigned to the page.

Example: (Where All caps will be different based on page information)

Hi David,
It looks like the example you posted contained some code that got stripped out. You can ensure the code doesn’t get stripped by enclosing it like this:

 Code goes here.

Here’s the sample code

<script type="text/javascript">
<br />
var WebAnalytics = { Page: { PageIdentifier: "PRODUCTS" } };
<br />
webanalytics = { page: { pageid:'BASKETBALL',categoryid:'9912ALL',searchterm:'',searchresults:'',attributes:'',extrafields:''}};
<br /> </script>   

Hi David,

There are many ways to do this, but one method that comes to mind would be to edit the meta-data of your pages through CM1 and manually input a tag through the Tags and Categories menu. This would serve as your page’s unique value. Then you could use jQuery on the template level to retrieve this value in your script:


Can you give me an example of what a tag looks like? What format does it look like?

Once example tag is added to page meta data - what exactly does the code look like on the template? You have sample code above, but what does it look like based on the example tag added to page?

Is there any doumentation for this? I’m not seeing it.


When you have a page open for editing in CM1, you can hover over Actions and select Edit-meta data. This will bring up a menu through which you can input and change various meta-data values.

For example, if you where to add in a tag such as “MyTag”, in the published version of that page you will see this in the head area of your HTML source:

<meta property="perc:tags" content="MyTag">

In this case, the jQuery code above would return “MyTag”. Note that if you’re already tagged these pages for use with our taxonomy widgets (Tags, Categories) – or plan to do so in the future – then this particular method could interfere with a typical page-tagging system. In that case, you could use any other meta property for this unique value, such as Display title (or “link text”). The jQuery to pull in your page’s CM1 link text would be this:


Hi David,

I take your retraction of your question to indicate that you have already found the answer you were looking for, but just to be sure (and also because I typed up this response before I saw you had removed yours!), if you’re adding two tags to you page, the tags will actually appear in two separate meta tag elements. That being the case, you can simply add a matched elements index selector to your code.

For example, if you have two tags applied to a page, ‘MyTag’ and ‘OtherTag’, you could pull in the first with:


And the second with:


Again, I’m not sure exactly what your application will be here and how many pages you would want to tag in such a manner, but this approach could interfere with an existing page tagging implementation you might already have in place, so please keep that in mind.

Thanks - I will need that later.