How to add a script to custom pages?

New Member
4 0 0

I created a custom page and need to add the following code to it. I'm not sure how this is done? Any help appreciated?

<div id="papAffiliateInfo" style="display:none">
<b>You're shopping with Affiliate:</b>
<span id="papname"></span>
<span id="papemail"></span>
<span id="papphoto"></span>
</div>
<script type="text/javascript" id="pap_x2s6df8d" src="https://unfilteredgear.postaffiliatepro.com/scripts/trackjs.js"></script>
<script type="text/javascript">
PostAffTracker.setAccountId('default1');
try {
PostAffTracker.track();
} catch (err) { }
PostAffTracker.executeOnResponceFinished.push(function() {
PostAffTracker.getAffInfo().call(function() {
var papAffID = PostAffTracker.getAffInfo().getAffiliateId();
var affInfoScript = document.createElement('script');
affInfoScript.setAttribute('src','http://unfilteredgear.postaffiliatepro.com/plugins/AffiliateInfo/affiliateinfo.php?userId=' + papAffID + '&param=all');
affInfoScript.setAttribute('type','text/javascript');
document.body.appendChild(affInfoScript);
});
});
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
for (i = 0; i < mutations.length; i++) {
for (j = 0; j < mutations[i].addedNodes.length; j++) {
if(mutations[i].addedNodes[j].nodeName == '#text' || mutations[i].addedNodes[j].nodeName == 'IMG') {
document.getElementById('papAffiliateInfo').style.display='block';
}
}
}
});

observer.observe(document.getElementById('papAffiliateInfo'), {
subtree: true,
childList: true
});
</script>

0 Likes
Shopify Expert
2529 424 535

Hi @ShellyEuabnks 

Its simple to do.

If you want to add in any custom page then create alternative page template

Open Template->create new template and select page.

Open it and paste your code in this template. if Js not work then add it to Asset->theme.js file

 

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
New Member
4 0 0

Thank you for your reply. 

 

I have added a new page, but I don't see any place that references Create a Template? I see where I can select a template, but that is it? Where would I find this? Perhaps I am just overlooking it. I am brand new to shopify so still learning my way around it. 

 

Thank you again for your help. Much appreciated. 

0 Likes
New Member
4 0 0

Here is what I seepage.png

0 Likes
Shopify Expert
2529 424 535

Just click on html viewer button from top right and paste your code.

 

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes
New Member
4 0 0

Ok yes that is what I did you can see my code in there now) and it didn't work. 

 

 

0 Likes
Shopify Expert
2529 424 535

if it not work then do this:

1. Create alternate template from Template->new template and create page template for that.

2. Add your all code in this page.

2. Assign this new page template for only this page. from Online store->pages

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
Want to get Free review and advice for sale on store ?? just text me here
0 Likes